From d535a5cb818e93fdb882b2748621d7367c013113 Mon Sep 17 00:00:00 2001 From: jhb Date: Mon, 17 Apr 2006 18:20:38 +0000 Subject: 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. --- sys/kern/uipc_mqueue.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sys/kern/uipc_mqueue.c') diff --git a/sys/kern/uipc_mqueue.c b/sys/kern/uipc_mqueue.c index a6587d5..e95f800 100644 --- a/sys/kern/uipc_mqueue.c +++ b/sys/kern/uipc_mqueue.c @@ -1657,7 +1657,7 @@ _mqueue_send(struct mqueue *mq, struct mqueue_msg *msg, int timo) } mq->mq_senders++; error = msleep(&mq->mq_senders, &mq->mq_mutex, - curthread->td_priority | PCATCH, "mqsend", timo); + PCATCH, "mqsend", timo); mq->mq_senders--; if (error == EAGAIN) error = ETIMEDOUT; @@ -1809,7 +1809,7 @@ _mqueue_recv(struct mqueue *mq, struct mqueue_msg **msg, int timo) } mq->mq_receivers++; error = msleep(&mq->mq_receivers, &mq->mq_mutex, - curthread->td_priority | PCATCH, "mqrecv", timo); + PCATCH, "mqrecv", timo); mq->mq_receivers--; if (error == EAGAIN) error = ETIMEDOUT; -- cgit v1.1