diff options
author | jhb <jhb@FreeBSD.org> | 2006-04-17 18:20:38 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2006-04-17 18:20:38 +0000 |
commit | d535a5cb818e93fdb882b2748621d7367c013113 (patch) | |
tree | 6e1e68443c878ae084bc35e7e36a8edf68ad3352 /sys/dev/random/randomdev_soft.c | |
parent | b4b950d049176bd4834f960bca79c4a2bdfd88c4 (diff) | |
download | FreeBSD-src-d535a5cb818e93fdb882b2748621d7367c013113.zip FreeBSD-src-d535a5cb818e93fdb882b2748621d7367c013113.tar.gz |
Change msleep() and tsleep() to not alter the calling thread's priority
if the specified priority is zero. This avoids a race where the calling
thread could read a snapshot of it's current priority, then a different
thread could change the first thread's priority, then the original thread
would call sched_prio() inside msleep() undoing the change made by the
second thread. I used a priority of zero as no thread that calls msleep()
or tsleep() should be specifying a priority of zero anyway.
The various places that passed 'curthread->td_priority' or some variant
as the priority now pass 0.
Diffstat (limited to 'sys/dev/random/randomdev_soft.c')
-rw-r--r-- | sys/dev/random/randomdev_soft.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/sys/dev/random/randomdev_soft.c b/sys/dev/random/randomdev_soft.c index cd5e2d9..159d6ce 100644 --- a/sys/dev/random/randomdev_soft.c +++ b/sys/dev/random/randomdev_soft.c @@ -211,8 +211,7 @@ random_yarrow_deinit(void) * Command the hash/reseed thread to end and wait for it to finish */ random_kthread_control = -1; - tsleep((void *)&random_kthread_control, curthread->td_priority, "term", - 0); + tsleep((void *)&random_kthread_control, 0, "term", 0); /* Destroy the harvest fifos */ while (!STAILQ_EMPTY(&emptyfifo.head)) { @@ -285,8 +284,7 @@ random_kthread(void *arg __unused) /* Found nothing, so don't belabour the issue */ if (!active) - tsleep(&harvestfifo, curthread->td_priority, "-", - hz / 10); + tsleep(&harvestfifo, 0, "-", hz / 10); } |