[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1400012857-11733-6-git-send-email-davidlohr@hp.com>
Date: Tue, 13 May 2014 13:27:37 -0700
From: Davidlohr Bueso <davidlohr@...com>
To: manfred@...orfullife.com, akpm@...ux-foundation.org
Cc: davidlohr@...com, aswin@...com, linux-kernel@...r.kernel.org
Subject: [PATCH 5/5] ipc,msg: loosen check for full queue
When sending a message, we must guarantee that there will be
enough room in the queue to add it, otherwise wait until space
becomes available -- which requires blocking the calling task.
Currently, this relies meeting both of the following conditions:
(i) The new msg size + current size is lower than the queue's max size.
(ii) The current amount of messages in the queue + 1 (this msg) is lower
than the queue's max size.
While (i) is obvious and well documented in the msgsnd(2) manpage, the
second one is far more ambiguous and does not serve the purpose, as we do
not control the amount of messages in the queue (unlike posix queues do).
Thus remove (ii) and loosen how we check for space.
Signed-off-by: Davidlohr Bueso <davidlohr@...com>
---
ipc/msg.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/ipc/msg.c b/ipc/msg.c
index 956cd65..7d267d0 100644
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -658,10 +658,8 @@ long do_msgsnd(int msqid, long mtype, void __user *mtext,
if (err)
goto out_unlock0;
- if (msgsz + msq->q_cbytes <= msq->q_qbytes &&
- 1 + msq->q_qnum <= msq->q_qbytes) {
- break;
- }
+ if (msgsz + msq->q_cbytes <= msq->q_qbytes)
+ break; /* there is space in the queue for this msg */
/* queue full, wait: */
if (msgflg & IPC_NOWAIT) {
--
1.8.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists