]> git.pld-linux.org Git - packages/libgcrypt.git/blob - libgcrypt-poll.patch
up to 1.9.0
[packages/libgcrypt.git] / libgcrypt-poll.patch
1 --- libgcrypt-1.8.0/random/rndlinux.c.orig      2017-06-24 13:34:29.000000000 +0200
2 +++ libgcrypt-1.8.0/random/rndlinux.c   2017-07-29 10:42:28.147643001 +0200
3 @@ -32,6 +32,7 @@
4  #include <string.h>
5  #include <unistd.h>
6  #include <fcntl.h>
7 +#include <poll.h>
8  #if defined(__linux__) || !defined(HAVE_GETENTROPY)
9  #ifdef HAVE_SYSCALL
10  # include <sys/syscall.h>
11 @@ -216,8 +217,7 @@
12                   return with something we will actually use 100ms. */
13    while (length)
14      {
15 -      fd_set rfds;
16 -      struct timeval tv;
17 +      struct pollfd fds;
18        int rc;
19  
20        /* If we have a modern Linux kernel and we want to read from the
21 @@ -276,21 +276,11 @@
22            any_need_entropy = 1;
23          }
24  
25 -      /* If the system has no limit on the number of file descriptors
26 -         and we encounter an fd which is larger than the fd_set size,
27 -         we don't use the select at all.  The select code is only used
28 -         to emit progress messages.  A better solution would be to
29 -         fall back to poll() if available.  */
30 -#ifdef FD_SETSIZE
31 -      if (fd < FD_SETSIZE)
32 -#endif
33          {
34 -          FD_ZERO(&rfds);
35 -          FD_SET(fd, &rfds);
36 -          tv.tv_sec = delay;
37 -          tv.tv_usec = delay? 0 : 100000;
38 +          fds.fd = fd;
39 +          fds.events = POLLIN;
40            _gcry_pre_syscall ();
41 -          rc = select (fd+1, &rfds, NULL, NULL, &tv);
42 +          rc = poll(&fds, 1, delay ? (delay*1000) : 100);
43            _gcry_post_syscall ();
44            if (!rc)
45              {
46 @@ -300,7 +290,7 @@
47              }
48            else if( rc == -1 )
49              {
50 -              log_error ("select() error: %s\n", strerror(errno));
51 +              log_error ("poll() error: %s\n", strerror(errno));
52                if (!delay)
53                  delay = 1; /* Use 1 second if we encounter an error before
54                                we have ever blocked.  */
This page took 0.140197 seconds and 3 git commands to generate.