From 61bee88d456c39bdfa4799577a4bd183d766b596 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Thu, 31 Oct 2002 15:17:16 -0500 Subject: [PATCH] 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. --- lib/uuid/ChangeLog | 6 ++++++ lib/uuid/gen_uuid.c | 5 +---- 2 files changed, 7 insertions(+), 4 deletions(-) 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; } -- 1.8.3.1