[Pkg-gnupg-commit] [libassuan] 229/437: 2008-03-21 Marcus Brinkmann <marcus at g10code.de>
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 3de69e5fece18cf9d0b417e34c600d0261bc4728
Author: Marcus Brinkmann <mb at g10code.com>
Date: Fri Mar 21 14:18:22 2008 +0000
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.
---
src/ChangeLog | 6 ++++++
src/assuan-defs.h | 5 ++++-
src/assuan-io-pth.c | 9 ++++++++-
src/assuan-io.c | 24 +++++++++++++++++++++++-
src/mkerrors | 9 +++------
5 files changed, 44 insertions(+), 9 deletions(-)
diff --git a/src/ChangeLog b/src/ChangeLog
index c2ba1df..6ac96e8 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -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.
diff --git a/src/assuan-defs.h b/src/assuan-defs.h
index b299435..e2d0f52 100644
--- a/src/assuan-defs.h
+++ b/src/assuan-defs.h
@@ -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_sendmsg (assuan_context_t ctx, struct msghdr *msg);
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);
diff --git a/src/assuan-io-pth.c b/src/assuan-io-pth.c
index 5b60cc7..6064ec4 100644
--- a/src/assuan-io-pth.c
+++ b/src/assuan-io-pth.c
@@ -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 @@ _assuan_simple_recvmsg (assuan_context_t ctx, struct msghdr *msg)
return ret;
#endif
}
+
+
+void
+_assuan_usleep (unsigned int usec)
+{
+ pth_usleep (usec);
+}
diff --git a/src/assuan-io.c b/src/assuan-io.c
index 1ff4ecb..17e8b46 100644
--- a/src/assuan-io.c
+++ b/src/assuan-io.c
@@ -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 @@ _assuan_simple_recvmsg (assuan_context_t ctx, struct msghdr *msg)
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
+}
diff --git a/src/mkerrors b/src/mkerrors
index 5c00836..79ac23b 100755
--- a/src/mkerrors
+++ b/src/mkerrors
@@ -28,12 +28,10 @@ cat <<EOF
#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 @@ _assuan_error_is_eagain (assuan_error_t err)
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
--
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