[haiku-commits] Change in haiku[master]: kernel/xsi_msg: if MessageQueueID() is -1, the message queue doesn't ...

  • From: Gerrit <review@xxxxxxxxxxxxxxxxxxx>
  • To: waddlesplash <waddlesplash@xxxxxxxxx>, haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 18 Jan 2021 20:02:08 +0000

From Jérôme Duval <jerome.duval@xxxxxxxxx>:

Jérôme Duval has uploaded this change for review. ( 
https://review.haiku-os.org/c/haiku/+/3643 ;)


Change subject: kernel/xsi_msg: if MessageQueueID() is -1, the message queue 
doesn't exist
......................................................................

kernel/xsi_msg: if MessageQueueID() is -1, the message queue doesn't exist

fix #16757
---
M src/system/kernel/posix/xsi_message_queue.cpp
1 file changed, 8 insertions(+), 6 deletions(-)



  git pull ssh://git.haiku-os.org:22/haiku refs/changes/43/3643/1

diff --git a/src/system/kernel/posix/xsi_message_queue.cpp 
b/src/system/kernel/posix/xsi_message_queue.cpp
index b2807ab..4037d38 100644
--- a/src/system/kernel/posix/xsi_message_queue.cpp
+++ b/src/system/kernel/posix/xsi_message_queue.cpp
@@ -660,19 +660,21 @@
                // Check if key already exist, if it does it already has a 
message
                // queue associated with it
                ipcKey = sIpcHashTable.Lookup(key);
-               if (ipcKey == NULL) {
+               if (ipcKey == NULL || ipcKey->MessageQueueID() == -1) {
                        if (!(flags & IPC_CREAT)) {
                                TRACE_ERROR(("xsi_msgget: key %d does not 
exist, but the "
                                        "caller did not ask for creation\n", 
(int)key));
                                return ENOENT;
                        }
-                       ipcKey = new(std::nothrow) Ipc(key);
                        if (ipcKey == NULL) {
-                               TRACE_ERROR(("xsi_msgget: failed to create new 
Ipc object "
-                                       "for key %d\n", (int)key));
-                               return ENOMEM;
+                               ipcKey = new(std::nothrow) Ipc(key);
+                               if (ipcKey == NULL) {
+                                       TRACE_ERROR(("xsi_msgget: failed to 
create new Ipc object "
+                                               "for key %d\n", (int)key));
+                                       return ENOMEM;
+                               }
+                               sIpcHashTable.Insert(ipcKey);
                        }
-                       sIpcHashTable.Insert(ipcKey);
                } else {
                        // The IPC key exist and it already has a message queue
                        if ((flags & IPC_CREAT) && (flags & IPC_EXCL)) {

--
To view, visit https://review.haiku-os.org/c/haiku/+/3643
To unsubscribe, or for help writing mail filters, visit 
https://review.haiku-os.org/settings

Gerrit-Project: haiku
Gerrit-Branch: master
Gerrit-Change-Id: I7c381e18c468b8c209fb275ef5e899c49aa26ffd
Gerrit-Change-Number: 3643
Gerrit-PatchSet: 1
Gerrit-Owner: Jérôme Duval <jerome.duval@xxxxxxxxx>
Gerrit-MessageType: newchange

Other related posts:

  • » [haiku-commits] Change in haiku[master]: kernel/xsi_msg: if MessageQueueID() is -1, the message queue doesn't ... - Gerrit