[Pkg-gnupg-commit] [libassuan] 233/437: Support sustems without nanosleep()
Eric Dorland
eric at moszumanska.debian.org
Fri May 22 05:33:47 UTC 2015
This is an automated email from the git hooks/post-receive script.
eric pushed a commit to branch master
in repository libassuan.
commit b0e33756457f6d3b5daa250bd342d3f2275bc10b
Author: Werner Koch <wk at gnupg.org>
Date: Mon Sep 1 10:39:24 2008 +0000
Support sustems without nanosleep()
---
src/ChangeLog | 5 +++++
src/assuan-io.c | 34 +++++++++++++++++++++-------------
2 files changed, 26 insertions(+), 13 deletions(-)
diff --git a/src/ChangeLog b/src/ChangeLog
index ada7d46..f41e2c8 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2008-09-01 Werner Koch <wk at g10code.com>
+
+ * assuan-io.c: Include time.h. Fixes bug#951.
+ (_assuan_usleep): Use nanosleep only is available.
+
2008-03-25 Marcus Brinkmann <marcus at g10code.de>
* assuan-inquire.c (assuan_inquire): Loop over _assuan_read_line
diff --git a/src/assuan-io.c b/src/assuan-io.c
index 17e8b46..647237d 100644
--- a/src/assuan-io.c
+++ b/src/assuan-io.c
@@ -21,6 +21,7 @@
#include <config.h>
#endif
+#include <time.h>
#include <sys/time.h>
#include <sys/types.h>
#ifdef HAVE_SYS_SOCKET_H
@@ -218,20 +219,27 @@ _assuan_simple_recvmsg (assuan_context_t ctx, struct msghdr *msg)
void
_assuan_usleep (unsigned int usec)
{
-#ifdef HAVE_W32_SYSTEM
- /* FIXME. */
- Sleep (usec / 1000);
+ if (usec)
+ {
+#ifdef HAVE_NANOSLEEP
+ struct timespec req;
+ struct timespec rem;
+
+ req.tv_sec = 0;
+ req.tv_nsec = usec * 1000;
+
+ while (nanosleep (&req, &rem) < 0 && errno == EINTR)
+ req = rem;
+
+#elif defined(HAVE_W32_SYSTEM)
+ Sleep (usec / 1000);
#else
- struct timespec req;
- struct timespec rem;
-
- if (usec == 0)
- return;
+ struct timeval tv;
- req.tv_sec = 0;
- req.tv_nsec = usec * 1000;
-
- while (nanosleep (&req, &rem) < 0 && errno == EINTR)
- req = rem;
+ tv.tv_sec = usec / 1000000;
+ tv.tv_usec = usec % 1000000;
+ select (0, NULL, NULL, NULL, &tv);
#endif
+ }
}
+
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/libassuan.git
More information about the Pkg-gnupg-commit
mailing list