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
Fixes-commit: 149041b0b9
Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2017-11-15 15:30:21 +01:00
parent 8704304699
commit 0cfdd3b57d
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
3 changed files with 15 additions and 5 deletions

View File

@ -337,7 +337,10 @@ wait_for_sock (int secs, int which, const char *sockname,
{
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 (which == 1?

View File

@ -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*/

View File

@ -1193,6 +1193,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, ':'))
{