diff options
| author | Mark Murray <markm@FreeBSD.org> | 2004-04-12 09:13:24 +0000 |
|---|---|---|
| committer | Mark Murray <markm@FreeBSD.org> | 2004-04-12 09:13:24 +0000 |
| commit | f587c6bf9f621bcfa7110f7400f7e55835ad3e6c (patch) | |
| tree | 90bb3b6673820fc06eb0e3f24139a870667102db /sys/dev/random | |
| parent | 881c6e063e2937ab1dd5f61ae3b6e0584e006311 (diff) | |
Notes
Diffstat (limited to 'sys/dev/random')
| -rw-r--r-- | sys/dev/random/randomdev.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/dev/random/randomdev.c b/sys/dev/random/randomdev.c index 63af98ac387a..268159a66a5b 100644 --- a/sys/dev/random/randomdev.c +++ b/sys/dev/random/randomdev.c @@ -103,25 +103,28 @@ random_read(dev_t dev __unused, struct uio *uio, int flag) { int c, error = 0; + mtx_lock(&random_systat.lock); + /* Blocking logic */ while (!random_systat.seeded && !error) { if (flag & IO_NDELAY) error = EWOULDBLOCK; else - error = tsleep(&random_systat, + error = msleep(&random_systat, &random_systat.lock, PUSER | PCATCH, "block", 0); } /* The actual read */ if (!error) { - mtx_lock(&random_systat.lock); while (uio->uio_resid > 0 && !error) { c = MIN(uio->uio_resid, PAGE_SIZE); c = (*random_systat.read)(random_buf, c); error = uiomove(random_buf, c, uio); } - mtx_unlock(&random_systat.lock); } + + mtx_unlock(&random_systat.lock); + return (error); } |
