[DRBD-cvs] r1458 - trunk/user

drbd-user@lists.linbit.com drbd-user@lists.linbit.com
Tue, 27 Jul 2004 11:01:05 +0200 (CEST)


Author: phil
Date: 2004-07-27 11:01:05 +0200 (Tue, 27 Jul 2004)
New Revision: 1458

Modified:
   trunk/user/drbdadm_main.c
Log:
The timeouts for drbdsetup commands is not 5 seconds or 60 seconds.


Modified: trunk/user/drbdadm_main.c
===================================================================
--- trunk/user/drbdadm_main.c	2004-07-26 17:07:52 UTC (rev 1457)
+++ trunk/user/drbdadm_main.c	2004-07-27 09:01:05 UTC (rev 1458)
@@ -68,6 +68,11 @@
   int res_name_required;
 };
 
+struct cmd_timeout {
+  const char* cmd;
+  int timeout;
+};
+
 extern int yyparse();
 extern FILE* yyin;
 
@@ -136,6 +141,13 @@
   { "sh-md-idx",         sh_md_idx,   0                  ,0,1 }
 };
 
+struct cmd_timeout timeouts[] = {
+  // All other commands have a timeout of 5 seconds.
+  { "disk",              60 },
+  { "invalidate",        60 },
+  { "invalidate_remote", 60 }
+};
+
 #define ARRY_SIZE(A) (sizeof(A)/sizeof(A[0]))
 
 /*** These functions are used to the print the config ***/
@@ -381,9 +393,15 @@
   }
 
   if( !(flags&SF_MaySleep) ) {
+    int i,timeout=5;
     sigaction(SIGALRM,&sa,&so);
     alarm_raised=0;
-    alarm(25); // Reading the AL & BitMap can take some time.
+    for(i=0;i<ARRY_SIZE(timeouts);i++) {
+      if(!strcmp(timeouts[i].cmd,argv[2])) {
+	timeout = timeouts[i].timeout;
+      }
+    }
+    alarm(timeout);
   }
 
   if( (flags&SF_ReturnPid) ) {