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.
This commit is contained in:
Peter Wemm 2000-10-18 10:39:18 +00:00
parent 25f3f7c530
commit 93d88e0056

View File

@ -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;
}