kernel/xsi_msg: if MessageQueueID() is -1, the message queue doesn't exist
fix #16757 Change-Id: I7c381e18c468b8c209fb275ef5e899c49aa26ffd Reviewed-on: https://review.haiku-os.org/c/haiku/+/3643 Reviewed-by: Adrien Destugues <[email protected]> Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
@@ -660,19 +660,21 @@ _user_xsi_msgget(key_t key, int flags)
|
|||||||
// Check if key already exist, if it does it already has a message
|
// Check if key already exist, if it does it already has a message
|
||||||
// queue associated with it
|
// queue associated with it
|
||||||
ipcKey = sIpcHashTable.Lookup(key);
|
ipcKey = sIpcHashTable.Lookup(key);
|
||||||
if (ipcKey == NULL) {
|
if (ipcKey == NULL || ipcKey->MessageQueueID() == -1) {
|
||||||
if (!(flags & IPC_CREAT)) {
|
if (!(flags & IPC_CREAT)) {
|
||||||
TRACE_ERROR(("xsi_msgget: key %d does not exist, but the "
|
TRACE_ERROR(("xsi_msgget: key %d does not exist, but the "
|
||||||
"caller did not ask for creation\n", (int)key));
|
"caller did not ask for creation\n", (int)key));
|
||||||
return ENOENT;
|
return ENOENT;
|
||||||
}
|
}
|
||||||
ipcKey = new(std::nothrow) Ipc(key);
|
|
||||||
if (ipcKey == NULL) {
|
if (ipcKey == NULL) {
|
||||||
TRACE_ERROR(("xsi_msgget: failed to create new Ipc object "
|
ipcKey = new(std::nothrow) Ipc(key);
|
||||||
"for key %d\n", (int)key));
|
if (ipcKey == NULL) {
|
||||||
return ENOMEM;
|
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 {
|
} else {
|
||||||
// The IPC key exist and it already has a message queue
|
// The IPC key exist and it already has a message queue
|
||||||
if ((flags & IPC_CREAT) && (flags & IPC_EXCL)) {
|
if ((flags & IPC_CREAT) && (flags & IPC_EXCL)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user