diff options
author | Xin LI <delphij@FreeBSD.org> | 2018-09-09 17:12:31 +0000 |
---|---|---|
committer | Xin LI <delphij@FreeBSD.org> | 2018-09-09 17:12:31 +0000 |
commit | 7a8d26613918887296503ab39c06ba605f7880dd (patch) | |
tree | 4c69d92e344551c47ddbef7299481c6973b2470c /sys/dev/random | |
parent | 7877f59352ccd1aa9d627f2f05bbbe8d23759d64 (diff) | |
download | src-7a8d26613918887296503ab39c06ba605f7880dd.tar.gz src-7a8d26613918887296503ab39c06ba605f7880dd.zip |
random(4): Squash non-error timeout codes from tsleep(9).
In both scenarios a timeout (EWOULDBLOCK) is considered as a
normal condition and the error should not pop up to upper layers.
PR: 231181
Submitted by: cem
Reported by: lev
Reviewed by: vangyzen, markm, delphij
Approved by: re (kib)
Approved by: secteam (delphij)
Differential Revision: https://reviews.freebsd.org/D17049
Notes
Notes:
svn path=/head/; revision=338542
Diffstat (limited to 'sys/dev/random')
-rw-r--r-- | sys/dev/random/randomdev.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/sys/dev/random/randomdev.c b/sys/dev/random/randomdev.c index c7bb97c3a0fe..94bd2f1a4147 100644 --- a/sys/dev/random/randomdev.c +++ b/sys/dev/random/randomdev.c @@ -156,6 +156,10 @@ READ_RANDOM_UIO(struct uio *uio, bool nonblock) error = tsleep(&random_alg_context, PCATCH, "randseed", hz/10); if (error == ERESTART || error == EINTR) break; + /* Squash tsleep timeout condition */ + if (error == EWOULDBLOCK) + error = 0; + KASSERT(error == 0, ("unexpected tsleep error %d", error)); } if (error == 0) { read_rate_increment((uio->uio_resid + sizeof(uint32_t))/sizeof(uint32_t)); @@ -184,9 +188,13 @@ READ_RANDOM_UIO(struct uio *uio, bool nonblock) * uninterruptible syscalls. */ if (error == 0 && uio->uio_resid != 0 && - total_read % sigchk_period == 0) + total_read % sigchk_period == 0) { error = tsleep_sbt(&random_alg_context, PCATCH, "randrd", SBT_1NS, 0, C_HARDCLOCK); + /* Squash tsleep timeout condition */ + if (error == EWOULDBLOCK) + error = 0; + } } if (error == ERESTART || error == EINTR) error = 0; |