urngd: fix busy loop in case of ioctl cause high cpu usage

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
(cherry picked from commit 562227aa9b)
This commit is contained in:
lean 2021-06-21 11:52:55 +08:00 committed by Tianling Shen
parent 2436d166cb
commit 1faa702430
No known key found for this signature in database
GPG Key ID: 6850B6345C862176

View File

@ -0,0 +1,18 @@
--- a/urngd.c
+++ b/urngd.c
@@ -129,9 +129,14 @@ static size_t gather_entropy(struct urng
static void low_entropy_cb(struct uloop_fd *ufd, unsigned int events)
{
struct urngd *u = container_of(ufd, struct urngd, rnd_fd);
+ size_t res;
DEBUG(2, DEV_RANDOM " signals low entropy\n");
- gather_entropy(u);
+ res = gather_entropy(u);
+ if (!res) {
+ DEBUG(2, "gather_entropy failed, delaying further attempts\n");
+ sleep(60);
+ }
}
static void urngd_done(struct urngd *u)