• R/O
  • SSH

pm_diskd: Commit

※ リポジトリは、pm-diskd ブランチが https://github.com/linux-ha-japan/pm_diskd-1.0 へ、pm-diskd-2.0ブランチが https://github.com/linux-ha-japan/pm_diskd へ移行しました。

Pacemaker 対応ディスク故障監視機能。

Pacemaker-1.0公式リポジトリのクローンに対し、パッチ作成用のブランチを作成して管理する。
ブランチ名: pm-diskd

初回 hg clone 実行後は、hg update -r pm-diskd を実行すること。

Heartbeat-2.1.4 用 hb-diskd(*) のPacemaker対応版
(*) http://sourceforge.jp/projects/linux-ha/releases/?package_id=10555


Commit MetaInfo

Revision5d993c7af81a31066c60ca2f68019b5604fdd5c3 (tree)
Time2012-10-11 06:02:52
Author <hideoyamauchi@inte...>

Log Message

The sync of thread processing and the main processing.(I thank for Hiroshi Akamatsu.)

Change Summary

Incremental Difference

diff -r dd53345f4f38 -r 5d993c7af81a tools/diskd.c
--- a/tools/diskd.c Thu Aug 09 06:06:30 2012 +0900
+++ b/tools/diskd.c Thu Oct 11 06:02:52 2012 +0900
@@ -102,13 +102,15 @@
102102
103103 static GMutex *diskd_mutex = NULL; /* Thread Mutex */
104104 static GCond *diskd_cond = NULL; /* Thread Cond */
105+static GMutex *thread_start_mutex = NULL; /* Thread Start Mutex */
106+static GCond *thread_start_cond = NULL; /* Thread Start Cond */
105107 static gboolean diskd_thread_use = FALSE; /* Tthred Timer Flag */
106108 static GThread *th_timer = NULL; /* Thread Timer */
107109 static int timer_id = -1;
108110
109111 static void diskd_thread_timer_init(void);
110112 static void diskd_thread_create(void);
111-static void diskd_thread_timer_variable_free(gboolean);
113+static void diskd_thread_timer_variable_free(void);
112114 static void diskd_thread_condsend(void);
113115 static void diskd_thread_timer_end(void);
114116 void send_update(void);
@@ -214,12 +216,15 @@
214216
215217 g_thread_init (NULL);
216218
219+
220+ thread_start_mutex = g_mutex_new();
221+ thread_start_cond = g_cond_new();
217222 diskd_mutex = g_mutex_new();
218223 diskd_cond = g_cond_new();
219- if (diskd_mutex && diskd_cond) {
224+ if (diskd_mutex && diskd_cond && thread_start_mutex && thread_start_cond) {
220225 diskd_thread_use = TRUE;
221226 } else {
222- diskd_thread_timer_variable_free(FALSE);
227+ diskd_thread_timer_variable_free();
223228 crm_warn("Failed in the generation of the thread variable. The thread timer is not available.");
224229 }
225230 } else {
@@ -228,37 +233,26 @@
228233 }
229234 }
230235
231-static void diskd_thread_timer_variable_free(gboolean bwait)
236+static void diskd_thread_timer_variable_free()
232237 {
233- int icnt = 0;
234- int try_max = ((timeout / 2) == 0) ? 1 : (timeout / 2);
235-
236238 if (diskd_mutex != NULL) {
237- if (bwait) {
238- /* TODO:
239- An next error of glib sometimes occurs.
240- -- ERROR: crm_glib_handler: GThread: file gthread-posix.c: .. error 'Device or resource busy' during... --
241- We turn on processing to wait for LOCK liberation.
242- */
243- while(icnt < try_max){
244- if (g_mutex_trylock(diskd_mutex) == FALSE) {
245- crm_warn("Wait for the liberation of the lock of Mutex.(%d < %d)", icnt, try_max);
246- sleep(1);
247- } else {
248- break;
249- }
250- icnt++;
251- }
252- }
253- g_mutex_unlock(diskd_mutex);
254239 g_mutex_free(diskd_mutex);
255240 diskd_mutex = NULL;
256241 }
242+ if (thread_start_mutex != NULL) {
243+ g_mutex_free(thread_start_mutex);
244+ thread_start_mutex = NULL;
245+ }
257246
258247 if (diskd_cond != NULL) {
259248 g_cond_free(diskd_cond);
260249 diskd_cond = NULL;
261250 }
251+
252+ if (thread_start_cond != NULL) {
253+ g_cond_free(thread_start_cond);
254+ thread_start_cond = NULL;
255+ }
262256 }
263257
264258 static void diskd_thread_timer_end()
@@ -266,7 +260,7 @@
266260 if (diskd_thread_use == FALSE) return;
267261
268262
269- diskd_thread_timer_variable_free(TRUE);
263+ diskd_thread_timer_variable_free();
270264 }
271265
272266 static void diskd_thread_condsend()
@@ -296,6 +290,8 @@
296290 glong add_time = (timeout) * 1000 * 1000;
297291 gboolean bret;
298292
293+ g_mutex_lock(thread_start_mutex);
294+
299295 /* Awaiting a start */
300296 g_mutex_lock(diskd_mutex);
301297
@@ -303,6 +299,10 @@
303299 g_get_current_time(&gtime);
304300 g_time_val_add(&gtime, add_time);
305301
302+ g_cond_signal(thread_start_cond);
303+
304+ g_mutex_unlock(thread_start_mutex);
305+
306306 bret = g_cond_timed_wait(diskd_cond, diskd_mutex, &gtime);
307307 g_mutex_unlock(diskd_mutex);
308308
@@ -322,7 +322,7 @@
322322
323323 if (diskd_thread_use) {
324324
325- g_mutex_lock(diskd_mutex);
325+ g_mutex_lock(thread_start_mutex);
326326
327327 if (th_timer == NULL) {
328328 th_timer = g_thread_create ((GThreadFunc)diskd_thread_timer_func, NULL, TRUE, &gerr);
@@ -330,10 +330,14 @@
330330 crm_err("Cannot create diskd timer_thread. %s", gerr->message);
331331 g_error_free(gerr);
332332 diskd_thread_use = FALSE;
333+ g_mutex_unlock(thread_start_mutex);
333334 }
334335 }
335- sleep(1);
336- g_mutex_unlock(diskd_mutex);
336+
337+ if (th_timer != NULL) {
338+ g_cond_wait(thread_start_cond, thread_start_mutex);
339+ g_mutex_unlock(thread_start_mutex);
340+ }
337341 }
338342 }
339343
@@ -735,3 +739,5 @@
735739 {
736740 attrd_lazy_update('U', NULL, diskd_attr, diskcheck_value, attr_section, attr_set, "0");
737741 }
742+
743+
Show on old repository browser