Blame SOURCES/libgcrypt-1.8.4-use-poll.patch

4bbd51
diff -up libgcrypt-1.8.4/random/rndlinux.c.use-poll libgcrypt-1.8.4/random/rndlinux.c
4bbd51
--- libgcrypt-1.8.4/random/rndlinux.c.use-poll	2018-10-26 13:50:20.000000000 +0200
4bbd51
+++ libgcrypt-1.8.4/random/rndlinux.c	2018-11-20 15:51:56.760669058 +0100
66e42d
@@ -32,6 +32,7 @@
66e42d
 #include <string.h>
66e42d
 #include <unistd.h>
66e42d
 #include <fcntl.h>
66e42d
+#include <poll.h>
66e42d
 #if defined(__linux__) && defined(HAVE_SYSCALL)
66e42d
 # include <sys/syscall.h>
66e42d
 #endif
4bbd51
@@ -241,9 +242,8 @@ _gcry_rndlinux_gather_random (void (*add
66e42d
                  return with something we will actually use 100ms. */
66e42d
   while (length)
66e42d
     {
66e42d
-      fd_set rfds;
66e42d
-      struct timeval tv;
66e42d
       int rc;
66e42d
+      struct pollfd pfd;
66e42d
 
4bbd51
       /* If we have a modern Linux kernel, we first try to use the new
4bbd51
        * getrandom syscall.  That call guarantees that the kernel's
4bbd51
@@ -300,36 +300,25 @@ _gcry_rndlinux_gather_random (void (*add
66e42d
           any_need_entropy = 1;
66e42d
         }
66e42d
 
66e42d
-      /* If the system has no limit on the number of file descriptors
66e42d
-         and we encounter an fd which is larger than the fd_set size,
66e42d
-         we don't use the select at all.  The select code is only used
66e42d
-         to emit progress messages.  A better solution would be to
66e42d
-         fall back to poll() if available.  */
66e42d
-#ifdef FD_SETSIZE
66e42d
-      if (fd < FD_SETSIZE)
66e42d
-#endif
66e42d
+      pfd.fd = fd;
66e42d
+      pfd.events = POLLIN;
66e42d
+
66e42d
+      _gcry_pre_syscall ();
66e42d
+      rc = poll(&pfd, 1, delay);
66e42d
+      _gcry_post_syscall ();
66e42d
+      if (!rc)
66e42d
         {
66e42d
-          FD_ZERO(&rfds);
66e42d
-          FD_SET(fd, &rfds);
66e42d
-          tv.tv_sec = delay;
66e42d
-          tv.tv_usec = delay? 0 : 100000;
66e42d
-          _gcry_pre_syscall ();
66e42d
-          rc = select (fd+1, &rfds, NULL, NULL, &tv;;
66e42d
-          _gcry_post_syscall ();
66e42d
-          if (!rc)
66e42d
-            {
66e42d
-              any_need_entropy = 1;
66e42d
-              delay = 3; /* Use 3 seconds henceforth.  */
66e42d
-              continue;
66e42d
-            }
66e42d
-          else if( rc == -1 )
66e42d
-            {
66e42d
-              log_error ("select() error: %s\n", strerror(errno));
66e42d
-              if (!delay)
66e42d
-                delay = 1; /* Use 1 second if we encounter an error before
66e42d
-                              we have ever blocked.  */
66e42d
-              continue;
66e42d
-            }
66e42d
+          any_need_entropy = 1;
66e42d
+          delay = 3000; /* Use 3 seconds henceforth.  */
66e42d
+          continue;
66e42d
+        }
66e42d
+        else if( rc == -1 )
66e42d
+        {
66e42d
+          log_error ("poll() error: %s\n", strerror(errno));
66e42d
+          if (!delay)
66e42d
+            delay = 1000; /* Use 1 second if we encounter an error before
66e42d
+                          we have ever blocked.  */
66e42d
+          continue;
66e42d
         }
66e42d
 
66e42d
       do