[svn] assuan - r283 - trunk/src
svn author marcus
cvs at cvs.gnupg.org
Fri Mar 21 15:18:23 CET 2008
Author: marcus
Date: 2008-03-21 15:18:22 +0100 (Fri, 21 Mar 2008)
New Revision: 283
Modified:
trunk/src/ChangeLog
trunk/src/assuan-defs.h
trunk/src/assuan-io-pth.c
trunk/src/assuan-io.c
trunk/src/mkerrors
Log:
2008-03-21 Marcus Brinkmann <marcus at g10code.de>
* assuan-defs.h (_assuan_usleep): New prototype.
* assuan-io.c (_assuan_usleep): New function.
* assuan-io-pth.c (_assuan_usleep): New function.
* mkerrors: Do not incude <windows.h>, but assuan-defs.h.
(_assuan_error_is_eagain): Call _assuan_usleep.
Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog 2008-03-21 04:34:08 UTC (rev 282)
+++ trunk/src/ChangeLog 2008-03-21 14:18:22 UTC (rev 283)
@@ -1,5 +1,11 @@
2008-03-21 Marcus Brinkmann <marcus at g10code.de>
+ * assuan-defs.h (_assuan_usleep): New prototype.
+ * assuan-io.c (_assuan_usleep): New function.
+ * assuan-io-pth.c (_assuan_usleep): New function.
+ * mkerrors: Do not incude <windows.h>, but assuan-defs.h.
+ (_assuan_error_is_eagain): Call _assuan_usleep.
+
* mkerrors [HAVE_W32_SYSTEM]: Include <windows.h>
(_assuan_error_is_eagain) [HAVE_W32_SYSTEM]: Wait the tenth of a
second.
Modified: trunk/src/assuan-defs.h
===================================================================
--- trunk/src/assuan-defs.h 2008-03-21 04:34:08 UTC (rev 282)
+++ trunk/src/assuan-defs.h 2008-03-21 14:18:22 UTC (rev 283)
@@ -1,5 +1,5 @@
/* assuan-defs.c - Internal definitions to Assuan
- * Copyright (C) 2001, 2002, 2004, 2005, 2007 Free Software Foundation, Inc.
+ * Copyright (C) 2001, 2002, 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
*
* This file is part of Assuan.
*
@@ -302,6 +302,9 @@
ssize_t _assuan_simple_recvmsg (assuan_context_t ctx, struct msghdr *msg);
#endif
+void _assuan_usleep (unsigned int usec);
+
+
/*-- assuan-socket.c --*/
int _assuan_close (assuan_fd_t fd);
assuan_fd_t _assuan_sock_new (int domain, int type, int proto);
Modified: trunk/src/assuan-io-pth.c
===================================================================
--- trunk/src/assuan-io-pth.c 2008-03-21 04:34:08 UTC (rev 282)
+++ trunk/src/assuan-io-pth.c 2008-03-21 14:18:22 UTC (rev 283)
@@ -1,5 +1,5 @@
/* assuan-io-pth.c - Pth version of assua-io.c.
- * Copyright (C) 2002, 2004, 2006, 2007 Free Software Foundation, Inc.
+ * Copyright (C) 2002, 2004, 2006, 2007, 2008 Free Software Foundation, Inc.
*
* This file is part of Assuan.
*
@@ -182,3 +182,10 @@
return ret;
#endif
}
+
+
+void
+_assuan_usleep (unsigned int usec)
+{
+ pth_usleep (usec);
+}
Modified: trunk/src/assuan-io.c
===================================================================
--- trunk/src/assuan-io.c 2008-03-21 04:34:08 UTC (rev 282)
+++ trunk/src/assuan-io.c 2008-03-21 14:18:22 UTC (rev 283)
@@ -1,5 +1,5 @@
/* assuan-io.c - Wraps the read and write functions.
- * Copyright (C) 2002, 2004, 2006, 2007 Free Software Foundation, Inc.
+ * Copyright (C) 2002, 2004, 2006, 2007, 2008 Free Software Foundation, Inc.
*
* This file is part of Assuan.
*
@@ -213,3 +213,25 @@
return ret;
#endif
}
+
+
+void
+_assuan_usleep (unsigned int usec)
+{
+#ifdef HAVE_W32_SYSTEM
+ /* FIXME. */
+ Sleep (usec / 1000);
+#else
+ struct timespec req;
+ struct timespec rem;
+
+ if (usec == 0)
+ return;
+
+ req.tv_sec = 0;
+ req.tv_nsec = usec * 1000;
+
+ while (nanosleep (&req, &rem) < 0 && errno == EINTR)
+ req = rem;
+#endif
+}
Modified: trunk/src/mkerrors
===================================================================
--- trunk/src/mkerrors 2008-03-21 04:34:08 UTC (rev 282)
+++ trunk/src/mkerrors 2008-03-21 14:18:22 UTC (rev 283)
@@ -28,12 +28,10 @@
#include <stdio.h>
#include <assert.h>
#include <errno.h>
-#ifdef HAVE_W32_SYSTEM
-#include <windows.h>
-#endif
#undef _ASSUAN_IN_LIBASSUAN /* undef to get all error codes. */
#include "assuan.h"
+#include "assuan-defs.h"
/* If true the modern gpg-error style error codes are used in the
API. */
@@ -152,9 +150,8 @@
if ((!err_source && err == ASSUAN_Read_Error && errno == EAGAIN)
|| (err_source && (err & ((1 << 24) - 1)) == (6 | (1 << 15))))
{
-#ifdef HAVE_W32_SYSTEM
- Sleep (100);
-#endif
+ /* Avoid spinning by sleeping for one tenth of a second. */
+ _assuan_usleep (100000);
return 1;
}
else
More information about the Gnupg-commits
mailing list