aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2020-08-11 05:59:41 +0000
committerWerner Koch <[email protected]>2020-08-11 05:59:41 +0000
commitfd1340085bc6879436dd2882dc5178c133434675 (patch)
tree4a71b40855d55e54531edc7f38c9de387cb91f14
parentMake --lib-version work again. (diff)
downloadlibgpg-error-fd1340085bc6879436dd2882dc5178c133434675.tar.gz
libgpg-error-fd1340085bc6879436dd2882dc5178c133434675.zip
core,w32: Use timeout in es_poll even if there are no FDs.
* src/w32-estream.c (_gpgrt_w32_poll): Sleep if there are no handles to wait for. -- This better matches the semantics of poll and select and avoid busy waitins. We had this problem for example in the LDAP helper process reaper of GnuPG's Dirmngr. Signed-off-by: Werner Koch <[email protected]>
-rw-r--r--src/w32-estream.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/w32-estream.c b/src/w32-estream.c
index 8ce9419..5bb1bcf 100644
--- a/src/w32-estream.c
+++ b/src/w32-estream.c
@@ -861,11 +861,25 @@ _gpgrt_w32_poll (gpgrt_poll_t *fds, size_t nfds, int timeout)
trace_append (("%d/%c ", waitidx[i], waitinfo[i]));
trace_finish (("]"));
#endif /*ENABLE_TRACING*/
+
if (!any)
- return 0;
+ {
+ /* WFMO needs at least one object, thus we use use sleep here.
+ * INFINITE wait does not make any sense in this case, so we
+ * error out. */
+ if (timeout == -1)
+ {
+ _gpg_err_set_errno (EINVAL);
+ return -1;
+ }
+ if (timeout)
+ Sleep (timeout);
+ code = WAIT_TIMEOUT;
+ }
+ else
+ code = WaitForMultipleObjects (nwait, waitbuf, 0,
+ timeout == -1 ? INFINITE : timeout);
- code = WaitForMultipleObjects (nwait, waitbuf, 0,
- timeout == -1 ? INFINITE : timeout);
if (code < WAIT_OBJECT_0 + nwait)
{
/* This WFMO is a really silly function: It does return either