From: Remi Gacogne Date: Wed, 29 May 2019 14:05:25 +0000 (+0200) Subject: Don't close the random device on EINTR X-Git-Tag: dnsdist-1.4.0-beta1~8^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b973ba4db6b82f446b2c28c3ac563f55a2c047e6;p=thirdparty%2Fpdns.git Don't close the random device on EINTR --- diff --git a/pdns/dns_random.cc b/pdns/dns_random.cc index e2b8e45754..48b910c8f4 100644 --- a/pdns/dns_random.cc +++ b/pdns/dns_random.cc @@ -285,6 +285,10 @@ uint32_t dns_random(uint32_t upper_bound) { do { ssize_t got = read(urandom_fd, &num, sizeof(num)); if (got < 0) { + if (errno == EINTR) { + continue; + } + (void)close(urandom_fd); throw std::runtime_error("Cannot read random device"); }