From a6de716d7ec7b937956f665e24a30df964c0c245 Mon Sep 17 00:00:00 2001 From: David Xu Date: Fri, 2 Dec 2005 08:23:49 +0000 Subject: [PATCH] 1. Check if message priority is less than MQ_PRIO_MAX. 2. Use getnanotime instead of getnanouptime. 3. Don't free message in _mqueue_send, mqueue_send will free it. --- sys/kern/uipc_mqueue.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sys/kern/uipc_mqueue.c b/sys/kern/uipc_mqueue.c index 95903b52f893..f5f675f06cd2 100644 --- a/sys/kern/uipc_mqueue.c +++ b/sys/kern/uipc_mqueue.c @@ -1569,6 +1569,8 @@ mqueue_send(struct mqueue *mq, const char *msg_ptr, struct timeval tv; int error; + if (msg_prio >= MQ_PRIO_MAX) + return (EINVAL); if (msg_len > mq->mq_msgsize) return (EMSGSIZE); msg = mqueue_loadmsg(msg_ptr, msg_len, msg_prio); @@ -1608,7 +1610,7 @@ mqueue_send(struct mqueue *mq, const char *msg_ptr, } for (;;) { ts2 = ets; - getnanouptime(&ts); + getnanotime(&ts); timespecsub(&ts2, &ts); if (ts2.tv_sec < 0 || (ts2.tv_sec == 0 && ts2.tv_nsec <= 0)) { error = ETIMEDOUT; @@ -1639,7 +1641,6 @@ _mqueue_send(struct mqueue *mq, struct mqueue_msg *msg, int timo) while (mq->mq_curmsgs >= mq->mq_maxmsg && error == 0) { if (timo < 0) { mtx_unlock(&mq->mq_mutex); - mqueue_freemsg(msg); return (EAGAIN); } mq->mq_senders++; @@ -1754,7 +1755,7 @@ mqueue_receive(struct mqueue *mq, char *msg_ptr, for (;;) { ts2 = ets; - getnanouptime(&ts); + getnanotime(&ts); timespecsub(&ts2, &ts); if (ts2.tv_sec < 0 || (ts2.tv_sec == 0 && ts2.tv_nsec <= 0)) { error = ETIMEDOUT;