]> git.pld-linux.org Git - packages/libgcrypt.git/blame - libgcrypt-poll.patch
up to 1.9.0
[packages/libgcrypt.git] / libgcrypt-poll.patch
CommitLineData
e7d29211
JB
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
37929a93
JB
3@@ -32,6 +32,7 @@
4 #include <string.h>
5 #include <unistd.h>
6 #include <fcntl.h>
7+#include <poll.h>
099faaf4
JP
8 #if defined(__linux__) || !defined(HAVE_GETENTROPY)
9 #ifdef HAVE_SYSCALL
a6d77427 10 # include <sys/syscall.h>
e7d29211 11@@ -216,8 +217,7 @@
37929a93
JB
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
e7d29211
JB
20 /* If we have a modern Linux kernel and we want to read from the
21@@ -276,21 +276,11 @@
c4b9e883
JB
22 any_need_entropy = 1;
23 }
24
9f887196
JB
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
a6d77427 33 {
9f887196
JB
34- FD_ZERO(&rfds);
35- FD_SET(fd, &rfds);
36- tv.tv_sec = delay;
37- tv.tv_usec = delay? 0 : 100000;
9f887196
JB
38+ fds.fd = fd;
39+ fds.events = POLLIN;
e7d29211
JB
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)
37929a93 45 {
e7d29211 46@@ -300,7 +290,7 @@
9f887196
JB
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
c4b9e883 54 we have ever blocked. */
This page took 0.147371 seconds and 4 git commands to generate.