@@ -997,10 +997,6 @@ int main(int argc, char **argv, char **envp)
997997 }
998998 }
999999 }
1000- cl_log (LOG_DEBUG , "Delay start: %s%s%s" ,
1001- delay_start ? "yes (" : "no" ,
1002- delay_start ? (delay > 0 ? value : "msgwait" ) : "" ,
1003- delay_start ? ")" : "" );
10041000
10051001 value = get_env_option ("SBD_TIMEOUT_ACTION" );
10061002 if (value ) {
@@ -1307,37 +1303,53 @@ int main(int argc, char **argv, char **envp)
13071303 } else if (strcmp (argv [optind ], "ping" ) == 0 ) {
13081304 exit_status = ping_via_slots (argv [optind + 1 ], servants_leader );
13091305
1306+ } else
1307+ #endif
1308+ if (strcmp (argv [optind ], "query-watchdog" ) == 0 ) {
1309+ exit_status = watchdog_info ();
1310+ } else if (strcmp (argv [optind ], "test-watchdog" ) == 0 ) {
1311+ exit_status = watchdog_test ();
13101312 } else if (strcmp (argv [optind ], "watch" ) == 0 ) {
1313+ /* sleep $(sbd $SBD_DEVICE_ARGS dump | grep -m 1 msgwait | awk '{print $4}') 2>/dev/null */
1314+
1315+ const char * delay_source = delay ? "SBD_DELAY_START" : "" ;
1316+
1317+ #if SUPPORT_SHARED_DISK
13111318 if (disk_count > 0 ) {
13121319 /* If no devices are specified, its not an error to be unable to find one */
13131320 open_any_device (servants_leader );
1321+
1322+ if (delay_start && delay <= 0 ) {
1323+ delay = get_first_msgwait (servants_leader );
1324+
1325+ if (delay > 0 ) {
1326+ delay_source = "msgwait" ;
1327+ } else {
1328+ cl_log (LOG_WARNING , "No 'msgwait' value from disk, using '2 * watchdog-timeout' for 'delay' starting" );
1329+ }
1330+ }
1331+ }
1332+ #endif
1333+ /* Re-calculate timeout_watchdog_warn based on any timeout_watchdog from:
1334+ * SBD_WATCHDOG_TIMEOUT, -1 option or on-disk setting read with open_any_device() */
1335+ if (do_calculate_timeout_watchdog_warn ) {
1336+ timeout_watchdog_warn = calculate_timeout_watchdog_warn (timeout_watchdog );
13141337 }
13151338
13161339 if (delay_start ) {
1340+ /* diskless mode or disk read issues causing get_first_msgwait() to return a 0 for delay */
13171341 if (delay <= 0 ) {
1318- delay = get_first_msgwait (servants_leader );
1342+ delay = 2 * timeout_watchdog ;
1343+ delay_source = "watchdog-timeout * 2" ;
13191344 }
13201345
1321- sleep ((unsigned long ) delay );
1322- }
1346+ cl_log (LOG_DEBUG , "Delay start (yes), (delay: %ld), (delay source: %s)" , delay , delay_source );
13231347
1324- } else {
1325- exit_status = -2 ;
1326- }
1327- #endif
1328-
1329- /* Re-calculate timeout_watchdog_warn based on any timeout_watchdog from:
1330- * SBD_WATCHDOG_TIMEOUT, -1 option or on-disk setting read with open_any_device() */
1331- if (do_calculate_timeout_watchdog_warn ) {
1332- timeout_watchdog_warn = calculate_timeout_watchdog_warn (timeout_watchdog );
1333- }
1348+ sleep ((unsigned long ) delay );
13341349
1335- if (strcmp (argv [optind ], "query-watchdog" ) == 0 ) {
1336- exit_status = watchdog_info ();
1337- } else if (strcmp (argv [optind ], "test-watchdog" ) == 0 ) {
1338- exit_status = watchdog_test ();
1339- } else if (strcmp (argv [optind ], "watch" ) == 0 ) {
1340- /* sleep $(sbd $SBD_DEVICE_ARGS dump | grep -m 1 msgwait | awk '{print $4}') 2>/dev/null */
1350+ } else {
1351+ cl_log (LOG_DEBUG , "Delay start (no)" );
1352+ }
13411353
13421354 /* We only want this to have an effect during watch right now;
13431355 * pinging and fencing would be too confused */
@@ -1357,6 +1369,8 @@ int main(int argc, char **argv, char **envp)
13571369 cl_log (LOG_NOTICE , "%s flush + write \'%c\' to sysrq in case of timeout" ,
13581370 do_flush ?"Do" :"Skip" , timeout_sysrq_char );
13591371 exit_status = inquisitor ();
1372+ } else {
1373+ exit_status = -2 ;
13601374 }
13611375
13621376 out :
0 commit comments