[svn] GnuPG - r5501 - trunk/common

svn author wk cvs at cvs.gnupg.org
Fri Dec 17 17:55:13 CET 2010


Author: wk
Date: 2010-12-17 17:55:13 +0100 (Fri, 17 Dec 2010)
New Revision: 5501

Modified:
   trunk/common/ChangeLog
   trunk/common/asshelp.c
Log:
Increase start timeout


Modified: trunk/common/ChangeLog
===================================================================
--- trunk/common/ChangeLog	2010-12-17 02:05:14 UTC (rev 5500)
+++ trunk/common/ChangeLog	2010-12-17 16:55:13 UTC (rev 5501)
@@ -1,3 +1,10 @@
+2010-12-17  Werner Koch  <wk at g10code.com>
+
+	* asshelp.c (lock_spawning): Add arg VERBOSE.  Improve timeout
+	management.  Make callers pass a value for VERBOSE.
+	(lock_agent_spawning, unlock_agent_spawning): Remove.  Change
+	callers to use lock_spawning and unlock_spawning.
+
 2010-12-17  Marcus Brinkmann  <mb at g10code.com>
 
 	* homedir.c (gnupg_cachedir): Create /temp subdirectories.
@@ -33,7 +40,7 @@
 	* gettime.c (gnupg_get_isotime): Compare to (time_t)-1.
 	(epoch2isotime): Ditto.
 	(IS_INVALID_TIME_T): New.
-	(asctimestamp): Use lNew macro.
+	(asctimestamp): Use new macro.
 	(strtimestamp, isotimestamp): Ditto.  Use snprintf.
 
 2010-10-25  Werner Koch  <wk at g10code.com>

Modified: trunk/common/asshelp.c
===================================================================
--- trunk/common/asshelp.c	2010-12-17 02:05:14 UTC (rev 5500)
+++ trunk/common/asshelp.c	2010-12-17 16:55:13 UTC (rev 5501)
@@ -229,11 +229,15 @@
    of a variable to store the lock information and the name or the
    process.  */
 static gpg_error_t
-lock_spawning (lock_spawn_t *lock, const char *homedir, const char *name)
+lock_spawning (lock_spawn_t *lock, const char *homedir, const char *name,
+               int verbose)
 {
 #ifdef HAVE_W32_SYSTEM
   int waitrc;
-  
+  int timeout = (!strcmp (name, "agent")
+                 ? SECS_TO_WAIT_FOR_AGENT
+                 : SECS_TO_WAIT_FOR_DIRMNGR);
+
   (void)homedir; /* Not required. */
 
   *lock = CreateMutexW 
@@ -248,10 +252,19 @@
       return gpg_error (GPG_ERR_GENERAL);
     }
 
-  waitrc = WaitForSingleObject (*lock, 5000);
+ retry:
+  waitrc = WaitForSingleObject (*lock, 1000);
   if (waitrc == WAIT_OBJECT_0)
     return 0;
-
+  
+  if (waitrc == WAIT_TIMEOUT && timeout)
+    {
+      timeout--;
+      if (verbose)
+        log_info ("another process is trying to start the %s ... (%ds)\n",
+                  name, timeout);
+      goto retry;
+    }
   if (waitrc == WAIT_TIMEOUT)
     log_info ("error waiting for the spawn_%s mutex: timeout\n", name);
   else
@@ -261,6 +274,8 @@
 #else /*!HAVE_W32_SYSTEM*/
   char *fname;
 
+  (void)verbose;
+
   *lock = NULL;
 
   fname = make_filename
@@ -306,22 +321,6 @@
     }
 }
 
-/* Lock the agent spawning process.  The caller needs to provide the
-   address of a variable to store the lock information.  */
-static gpg_error_t
-lock_agent_spawning (lock_spawn_t *lock, const char *homedir)
-{
-  return lock_spawning (lock, homedir, "agent");
-}
-
-
-static void
-unlock_agent_spawning (lock_spawn_t *lock)
-{
-  unlock_spawning (lock, "agent");
-}
-
-
 /* Try to connect to the agent via socket or fork it off and work by
    pipes.  Handle the server's initial greeting.  Returns a new assuan
    context at R_CTX or an error code. */
@@ -420,7 +419,7 @@
               argv[1] = "--use-standard-socket"; 
               argv[2] = NULL;  
 
-              if (!(err = lock_agent_spawning (&lock, homedir))
+              if (!(err = lock_spawning (&lock, homedir, "agent", verbose))
                   && assuan_socket_connect (ctx, sockname, 0, 0))
                 {
                   err = gnupg_spawn_process_detached (agent_program, argv,NULL);
@@ -453,7 +452,7 @@
                     }
                 }
 
-              unlock_agent_spawning (&lock);
+              unlock_spawning (&lock, "agent");
             }
           else
             {
@@ -614,7 +613,7 @@
       argv[0] = "--daemon";
       argv[1] = NULL;  
       
-      if (!(err = lock_spawning (&lock, homedir, "dirmngr"))
+      if (!(err = lock_spawning (&lock, homedir, "dirmngr", verbose))
           && assuan_socket_connect (ctx, sockname, 0, 0))
         {
           err = gnupg_spawn_process_detached (dirmngr_program, argv,NULL);





More information about the Gnupg-commits mailing list