summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authordavidxu <davidxu@FreeBSD.org>2005-12-02 08:23:49 +0000
committerdavidxu <davidxu@FreeBSD.org>2005-12-02 08:23:49 +0000
commita8411b92b7f1bffcd8f6d8f29066bdbd6f0ea5e1 (patch)
tree2c53def254693ca996325acf3a03fafb17999814 /sys
parentb07bfe20846b69910883ad716cef9170a7c99669 (diff)
downloadFreeBSD-src-a8411b92b7f1bffcd8f6d8f29066bdbd6f0ea5e1.zip
FreeBSD-src-a8411b92b7f1bffcd8f6d8f29066bdbd6f0ea5e1.tar.gz
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.
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/uipc_mqueue.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/sys/kern/uipc_mqueue.c b/sys/kern/uipc_mqueue.c
index 95903b5..f5f675f 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;
OpenPOWER on IntegriCloud