[PATCH gpgme] tests: Fix select usage in t-eventloop

Daiki Ueno ueno at gnu.org
Fri Feb 5 09:45:05 CET 2016


* tests/gpg/t-eventloop.c (do_select): Use the highest fd number plus 1,
as the first argument of select, and supply timeout value as struct
timeval.

Signed-off-by: Daiki Ueno <ueno at gnu.org>
---
 tests/gpg/t-eventloop.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/tests/gpg/t-eventloop.c b/tests/gpg/t-eventloop.c
index cb1e57c..a6918a8 100644
--- a/tests/gpg/t-eventloop.c
+++ b/tests/gpg/t-eventloop.c
@@ -111,16 +111,25 @@ do_select (void)
   fd_set wfds;
   int i, n;
   int any = 0;
+  int nfds = 0;
+  struct timeval tv;
 
   FD_ZERO (&rfds);
   FD_ZERO (&wfds);
   for (i = 0; i < FDLIST_MAX; i++)
     if (fdlist[i].fd != -1)
-      FD_SET (fdlist[i].fd, fdlist[i].dir ? &rfds : &wfds);
+      {
+	FD_SET (fdlist[i].fd, fdlist[i].dir ? &rfds : &wfds);
+	if (nfds < fdlist[i].fd)
+	  nfds = fdlist[i].fd;
+      }
+
+  tv.tv_sec = 0;
+  tv.tv_usec = 1000;
 
   do
     {
-      n = select (FD_SETSIZE, &rfds, &wfds, NULL, 0);
+      n = select (nfds + 1, &rfds, &wfds, NULL, &tv);
     }
   while (n < 0 && errno == EINTR);
 
-- 
2.5.0




More information about the Gnupg-devel mailing list