summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2010-12-17 17:55:13 +0100
committerWerner Koch <wk@gnupg.org>2010-12-17 17:55:13 +0100
commitf8317bef0239adfe55be79625701d6916eb083b7 (patch)
treee41069ce19f0753722788c0178d7dfc86cfc326b /common
parent2010-12-17 Marcus Brinkmann <mb@g10code.com> (diff)
downloadgnupg2-f8317bef0239adfe55be79625701d6916eb083b7.tar.xz
gnupg2-f8317bef0239adfe55be79625701d6916eb083b7.zip
Increase start timeout
Diffstat (limited to 'common')
-rw-r--r--common/ChangeLog9
-rw-r--r--common/asshelp.c45
2 files changed, 30 insertions, 24 deletions
diff --git a/common/ChangeLog b/common/ChangeLog
index 92f23c28f..de96b8dc8 100644
--- a/common/ChangeLog
+++ b/common/ChangeLog
@@ -1,3 +1,10 @@
+2010-12-17 Werner Koch <wk@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@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@g10code.com>
diff --git a/common/asshelp.c b/common/asshelp.c
index d75227769..b8be103fc 100644
--- a/common/asshelp.c
+++ b/common/asshelp.c
@@ -229,11 +229,15 @@ send_pinentry_environment (assuan_context_t ctx,
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 @@ lock_spawning (lock_spawn_t *lock, const char *homedir, const char *name)
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 @@ lock_spawning (lock_spawn_t *lock, const char *homedir, const char *name)
#else /*!HAVE_W32_SYSTEM*/
char *fname;
+ (void)verbose;
+
*lock = NULL;
fname = make_filename
@@ -306,22 +321,6 @@ unlock_spawning (lock_spawn_t *lock, const char *name)
}
}
-/* 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 @@ start_new_gpg_agent (assuan_context_t *r_ctx,
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 @@ start_new_gpg_agent (assuan_context_t *r_ctx,
}
}
- unlock_agent_spawning (&lock);
+ unlock_spawning (&lock, "agent");
}
else
{
@@ -614,7 +613,7 @@ start_new_dirmngr (assuan_context_t *r_ctx,
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);