[svn] assuan - r288 - trunk/src
svn author wk
cvs at cvs.gnupg.org
Mon Sep 1 12:39:25 CEST 2008
Author: wk
Date: 2008-09-01 12:39:24 +0200 (Mon, 01 Sep 2008)
New Revision: 288
Modified:
trunk/src/ChangeLog
trunk/src/assuan-io.c
Log:
Support sustems without nanosleep()
Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog 2008-05-27 11:45:44 UTC (rev 287)
+++ trunk/src/ChangeLog 2008-09-01 10:39:24 UTC (rev 288)
@@ -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
Modified: trunk/src/assuan-io.c
===================================================================
--- trunk/src/assuan-io.c 2008-05-27 11:45:44 UTC (rev 287)
+++ trunk/src/assuan-io.c 2008-09-01 10:39:24 UTC (rev 288)
@@ -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 @@
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;
+ struct timeval tv;
- if (usec == 0)
- return;
-
- 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
+ }
}
+
More information about the Gnupg-commits
mailing list