use poll() instead of select() when gathering randomness (#913773)
This commit is contained in:
parent
8df0581f5a
commit
6fb8d4d1e6
57
libgcrypt-1.5.0-use-poll.patch
Normal file
57
libgcrypt-1.5.0-use-poll.patch
Normal file
@ -0,0 +1,57 @@
|
||||
diff -up libgcrypt-1.5.0/random/rndlinux.c.use-poll libgcrypt-1.5.0/random/rndlinux.c
|
||||
--- libgcrypt-1.5.0/random/rndlinux.c.use-poll 2012-04-05 15:37:52.000000000 +0200
|
||||
+++ libgcrypt-1.5.0/random/rndlinux.c 2013-03-05 14:15:29.735709032 +0100
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
+#include <poll.h>
|
||||
#include "types.h"
|
||||
#include "g10lib.h"
|
||||
#include "rand-internal.h"
|
||||
@@ -142,21 +143,19 @@ _gcry_rndlinux_gather_random (void (*add
|
||||
}
|
||||
|
||||
/* Enter the read loop. */
|
||||
- delay = 0; /* Start with 0 seconds so that we do no block on the
|
||||
+ delay = 100; /* Start with 0 seconds so that we do no block on the
|
||||
first iteration and in turn call the progress function
|
||||
before blocking. To give the OS a better chance to
|
||||
return with something we will actually use 100ms. */
|
||||
while (length)
|
||||
{
|
||||
- fd_set rfds;
|
||||
- struct timeval tv;
|
||||
int rc;
|
||||
+ struct pollfd pfd;
|
||||
|
||||
- FD_ZERO(&rfds);
|
||||
- FD_SET(fd, &rfds);
|
||||
- tv.tv_sec = delay;
|
||||
- tv.tv_usec = delay? 0 : 100000;
|
||||
- if ( !(rc=select(fd+1, &rfds, NULL, NULL, &tv)) )
|
||||
+ pfd.fd = fd;
|
||||
+ pfd.events = POLLIN;
|
||||
+
|
||||
+ if ( !(rc=poll(&pfd, 1, delay)) )
|
||||
{
|
||||
if (!any_need_entropy || last_so_far != (want - length) )
|
||||
{
|
||||
@@ -165,14 +164,14 @@ _gcry_rndlinux_gather_random (void (*add
|
||||
(int)last_so_far, (int)want);
|
||||
any_need_entropy = 1;
|
||||
}
|
||||
- delay = 3; /* Use 3 seconds henceforth. */
|
||||
+ delay = 3000; /* Use 3 seconds henceforth. */
|
||||
continue;
|
||||
}
|
||||
else if( rc == -1 )
|
||||
{
|
||||
- log_error ("select() error: %s\n", strerror(errno));
|
||||
+ log_error ("poll() error: %s\n", strerror(errno));
|
||||
if (!delay)
|
||||
- delay = 1; /* Use 1 second if we encounter an error before
|
||||
+ delay = 1000; /* Use 1 second if we encounter an error before
|
||||
we have ever blocked. */
|
||||
continue;
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
Name: libgcrypt
|
||||
Version: 1.5.0
|
||||
Release: 10%{?dist}
|
||||
Release: 11%{?dist}
|
||||
URL: http://www.gnupg.org/
|
||||
Source0: libgcrypt-%{version}-hobbled.tar.bz2
|
||||
# The original libgcrypt sources now contain potentially patented ECC
|
||||
@ -27,6 +27,8 @@ Patch8: libgcrypt-1.5.0-set-enforced-mode.patch
|
||||
Patch9: libgcrypt-1.5.0-leak.patch
|
||||
# allow empty passphrase (upstreamed)
|
||||
Patch10: libgcrypt-1.5.0-empty-passphrase.patch
|
||||
# use poll instead of select when gathering randomness
|
||||
Patch11: libgcrypt-1.5.0-use-poll.patch
|
||||
|
||||
# Technically LGPLv2.1+, but Fedora's table doesn't draw a distinction.
|
||||
# Documentation and some utilities are GPLv2+ licensed. These files
|
||||
@ -69,6 +71,7 @@ applications using libgcrypt.
|
||||
%patch8 -p1 -b .enforce
|
||||
%patch9 -p1 -b .leak
|
||||
%patch10 -p1 -b .emptypass
|
||||
%patch11 -p1 -b .use-poll
|
||||
|
||||
mv AUTHORS AUTHORS.iso88591
|
||||
iconv -f ISO-8859-1 -t UTF-8 AUTHORS.iso88591 >AUTHORS
|
||||
@ -182,6 +185,9 @@ exit 0
|
||||
%doc COPYING
|
||||
|
||||
%changelog
|
||||
* Tue Mar 5 2013 Tomas Mraz <tmraz@redhat.com> 1.5.0-11
|
||||
- use poll() instead of select() when gathering randomness (#913773)
|
||||
|
||||
* Thu Feb 14 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.5.0-10
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user