summaryrefslogtreecommitdiffstats
path: root/sys/dev/random
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>2000-10-18 10:39:18 +0000
committerpeter <peter@FreeBSD.org>2000-10-18 10:39:18 +0000
commite6ed2cfb6c20d5b51bbc6ab288d8ba920dc1c1ac (patch)
tree68373b0dc256cc08dfcfbd7343dead64d6b8cac3 /sys/dev/random
parenta4104b417ea985c653c0668f77ffee40394327a6 (diff)
downloadFreeBSD-src-e6ed2cfb6c20d5b51bbc6ab288d8ba920dc1c1ac.zip
FreeBSD-src-e6ed2cfb6c20d5b51bbc6ab288d8ba920dc1c1ac.tar.gz
Attempt to fix the random read blocking. The old code slept at
priority "0" and without PCATCH, so it was uninterruptable. And even when it did wake up after entropy arrived, it exited after the wakeup without actually reading the freshly arrived entropy. I sent this to Mark before but it seems he is in transit. Mark: feel free to replace this if it gets in your way.
Diffstat (limited to 'sys/dev/random')
-rw-r--r--sys/dev/random/randomdev.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/sys/dev/random/randomdev.c b/sys/dev/random/randomdev.c
index eaa47b9..c8d2eba 100644
--- a/sys/dev/random/randomdev.c
+++ b/sys/dev/random/randomdev.c
@@ -109,22 +109,21 @@ random_read(dev_t dev, struct uio *uio, int flag)
int error = 0;
void *random_buf;
- if (flag & IO_NDELAY && !random_state.seeded) {
- error = EWOULDBLOCK;
- }
- else {
- if (random_state.seeded) {
- c = min(uio->uio_resid, PAGE_SIZE);
- random_buf = (void *)malloc(c, M_TEMP, M_WAITOK);
- while (uio->uio_resid > 0 && error == 0) {
- ret = read_random_real(random_buf, c);
- error = uiomove(random_buf, ret, uio);
- }
- free(random_buf, M_TEMP);
- }
+ while (!random_state.seeded) {
+ if (flag & IO_NDELAY)
+ error = EWOULDBLOCK;
else
- error = tsleep(&random_state, 0, "rndblk", 0);
+ error = tsleep(&random_state, PUSER|PCATCH, "rndblk", 0);
+ if (error != 0)
+ return error;
}
+ c = min(uio->uio_resid, PAGE_SIZE);
+ random_buf = (void *)malloc(c, M_TEMP, M_WAITOK);
+ while (uio->uio_resid > 0 && error == 0) {
+ ret = read_random_real(random_buf, c);
+ error = uiomove(random_buf, ret, uio);
+ }
+ free(random_buf, M_TEMP);
return error;
}
OpenPOWER on IntegriCloud