diff options
author | Werner Koch <wk@gnupg.org> | 2013-12-16 09:45:02 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2013-12-16 11:44:25 +0100 |
commit | 5a7ce59396fe56f0d681df314bfbdb5f7732d4b1 (patch) | |
tree | 11cf504323f799ccfc121461d8345dd47d713d4d /random | |
parent | dec048b2ec79271a2f4405be5b87b1e768b3f1a9 (diff) | |
download | libgcrypt-5a7ce59396fe56f0d681df314bfbdb5f7732d4b1.tar.gz |
random: Call random progress handler more often.
* random/rndlinux.c (_gcry_rndlinux_gather_random): Update progress
indicator earlier.
--
GnuPG-bug-id: 1531
Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'random')
-rw-r--r-- | random/rndlinux.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/random/rndlinux.c b/random/rndlinux.c index 21ea8c4b..89ac2031 100644 --- a/random/rndlinux.c +++ b/random/rndlinux.c @@ -183,6 +183,18 @@ _gcry_rndlinux_gather_random (void (*add)(const void*, size_t, struct timeval tv; int rc; + /* If we collected some bytes update the progress indicator. We + do this always and not just if the select timed out because + often just a few bytes are gathered within the timeout + period. */ + if (any_need_entropy || last_so_far != (want - length) ) + { + last_so_far = want - length; + _gcry_random_progress ("need_entropy", 'X', + (int)last_so_far, (int)want); + any_need_entropy = 1; + } + /* If the system has no limit on the number of file descriptors and we encounter an fd which is larger than the fd_set size, we don't use the select at all. The select code is only used @@ -198,13 +210,7 @@ _gcry_rndlinux_gather_random (void (*add)(const void*, size_t, tv.tv_usec = delay? 0 : 100000; if ( !(rc=select(fd+1, &rfds, NULL, NULL, &tv)) ) { - if (!any_need_entropy || last_so_far != (want - length) ) - { - last_so_far = want - length; - _gcry_random_progress ("need_entropy", 'X', - (int)last_so_far, (int)want); - any_need_entropy = 1; - } + any_need_entropy = 1; delay = 3; /* Use 3 seconds henceforth. */ continue; } |