From b973ba4db6b82f446b2c28c3ac563f55a2c047e6 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Wed, 29 May 2019 16:05:25 +0200 Subject: [PATCH] Don't close the random device on EINTR --- pdns/dns_random.cc | 4 ++++ 1 file changed, 4 insertions(+) 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"); } -- 2.47.2