From 38eb7c360bc4867cbaf37e3c2c0865bc6452ba4a Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Wed, 15 Nov 2017 15:30:21 +0100 Subject: 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 (cherry picked from commit 0cfdd3b57d592fb6baa7dafe8fde124e8a6c7798) Fixes-commit: 1189df2cd7d4b6896ba22aa204c159ff2a425ead Signed-off-by: Werner Koch --- common/sysutils.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'common/sysutils.c') 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*/ -- cgit v1.2.3