From: Theodore Ts'o Date: Thu, 31 Oct 2002 20:17:16 +0000 (-0500) Subject: gen_uuid.c (get_random_bytes): Don't spin forever if read() X-Git-Tag: E2FSPROGS-1_30~9 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=61bee88d456c39bdfa4799577a4bd183d766b596;p=tools%2Fe2fsprogs.git gen_uuid.c (get_random_bytes): Don't spin forever if read() returns EINTR or EAGAIN, so that when /dev/random is opened O_NONBLOCK, we don't end up spinning forever. --- diff --git a/lib/uuid/ChangeLog b/lib/uuid/ChangeLog index dab24df..3e7da5c 100644 --- a/lib/uuid/ChangeLog +++ b/lib/uuid/ChangeLog @@ -1,3 +1,9 @@ +2002-10-31 Theodore Ts'o + + * gen_uuid.c (get_random_bytes): Don't spin forever if read() + returns EINTR or EAGAIN, so that when /dev/random is + opened O_NONBLOCK, we don't end up spinning forever. + 2001-09-24 Theodore Tso * Release of E2fsprogs 1.29 diff --git a/lib/uuid/gen_uuid.c b/lib/uuid/gen_uuid.c index 1f72439..5ebc673 100644 --- a/lib/uuid/gen_uuid.c +++ b/lib/uuid/gen_uuid.c @@ -81,11 +81,8 @@ static void get_random_bytes(void *buf, int nbytes) if (fd >= 0) { while (nbytes > 0) { i = read(fd, cp, nbytes); - if ((i < 0) && - ((errno == EINTR) || (errno == EAGAIN))) - continue; if (i <= 0) { - if (lose_counter++ == 8) + if (lose_counter++ > 16) break; continue; }