aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2017-11-15 14:30:21 +0000
committerWerner Koch <[email protected]>2018-08-28 14:47:38 +0000
commit38eb7c360bc4867cbaf37e3c2c0865bc6452ba4a (patch)
treef5155454500c13a75764f3853cf7c692d410c544
parentassuan: Use exponential decay for first 1s of spinlock. (diff)
downloadgnupg-38eb7c360bc4867cbaf37e3c2c0865bc6452ba4a.tar.gz
gnupg-38eb7c360bc4867cbaf37e3c2c0865bc6452ba4a.zip
assuan: Fix exponential decay for first second.
* common/asshelp.c (wait_for_sock): Round SECSLEFT. * dirmngr/dirmngr.c (main): Take care of --debug-wait also in dameon mode. * common/sysutils.c (gnupg_usleep) [HAVE_NANOSLEEP]: Fix nanosleep use. -- Without the rounding we saw in verbose mose [...]to come up ... (5s) [...]to come up ... (4s) immediately without the expected one second delay. Waiting for the next seconds did not work if nanosleep was used due to improper passed parameters in gnupg_usleep. Adding --debug-wait for dirmngr in daemon mode is required to test this change. GnuPG-bug-id: 3490 Signed-off-by: Werner Koch <[email protected]> (cherry picked from commit 0cfdd3b57d592fb6baa7dafe8fde124e8a6c7798) Fixes-commit: 1189df2cd7d4b6896ba22aa204c159ff2a425ead Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to '')
-rw-r--r--common/asshelp.c5
-rw-r--r--common/sysutils.c7
-rw-r--r--dirmngr/dirmngr.c8
3 files changed, 15 insertions, 5 deletions
diff --git a/common/asshelp.c b/common/asshelp.c
index 76f812d8c..d87017eba 100644
--- a/common/asshelp.c
+++ b/common/asshelp.c
@@ -326,7 +326,10 @@ wait_for_sock (int secs, const char *name, const char *sockname, int verbose, as
{
if (verbose)
{
- secsleft = (target_us - elapsed_us)/1000000;
+ secsleft = (target_us - elapsed_us + 999999)/1000000;
+ /* log_clock ("left=%d last=%d targ=%d elap=%d next=%d\n", */
+ /* secsleft, lastalert, target_us, elapsed_us, */
+ /* next_sleep_us); */
if (secsleft < lastalert)
{
log_info (_("waiting for the %s to come up ... (%ds)\n"),
diff --git a/common/sysutils.c b/common/sysutils.c
index e90010c44..55a7ee9ec 100644
--- a/common/sysutils.c
+++ b/common/sysutils.c
@@ -340,11 +340,10 @@ gnupg_usleep (unsigned int usecs)
struct timespec req;
struct timespec rem;
- req.tv_sec = 0;
- req.tv_nsec = usecs * 1000;
-
+ req.tv_sec = usecs / 1000000;
+ req.tv_nsec = (usecs % 1000000) * 1000;
while (nanosleep (&req, &rem) < 0 && errno == EINTR)
- req = rem;
+ req = rem;
}
#else /*Standard Unix*/
diff --git a/dirmngr/dirmngr.c b/dirmngr/dirmngr.c
index 31f8e0f46..5965f84ef 100644
--- a/dirmngr/dirmngr.c
+++ b/dirmngr/dirmngr.c
@@ -1203,6 +1203,14 @@ main (int argc, char **argv)
current_logfile = xstrdup (logfile);
}
+ if (debug_wait)
+ {
+ log_debug ("waiting for debugger - my pid is %u .....\n",
+ (unsigned int)getpid());
+ gnupg_sleep (debug_wait);
+ log_debug ("... okay\n");
+ }
+
#ifndef HAVE_W32_SYSTEM
if (strchr (socket_name, ':'))
{