From c0a30e09776b8e3e4a7cd537247e1e642e448f72 Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Tue, 17 Sep 2019 14:49:28 +0200 Subject: [PATCH] Use better naming for msgQueue --- src/iface.h | 1 + src/queueClose.c | 3 ++- src/queueDelete.c | 9 ++++++++- src/queueElemDelete.c | 11 ++++++++++- src/queueOpen.c | 2 +- 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/iface.h b/src/iface.h index 7a2c43f..bb59dd8 100644 --- a/src/iface.h +++ b/src/iface.h @@ -69,6 +69,7 @@ typedef struct MsgSpaceList { } msgSpaceList; typedef struct MsgQueueElem { + msgQueueElemId id; int poolIndex; int bufferIndex; msgQueueElemId next; diff --git a/src/queueClose.c b/src/queueClose.c index afe521e..0f8ea7a 100644 --- a/src/queueClose.c +++ b/src/queueClose.c @@ -1,7 +1,8 @@ #include "libnazgul.h" #include "ids.h" +#include "libnazgul.h" -int queueClose(msgQueue * queue){ +int msgQueueClose(msgQueue * queue){ msgQueueId qId; strcpy(qId,queue->id); diff --git a/src/queueDelete.c b/src/queueDelete.c index 56b8fbf..64c05a3 100644 --- a/src/queueDelete.c +++ b/src/queueDelete.c @@ -5,7 +5,14 @@ int msgQueueElemDelete(msgQueueElemId queueElemId){ msgQueueElemId nextIdToDie; queueElemAddr = msgQueueElemOpen(queueElemId); - msgQueueElemClose(queueElem); + strcpy(nextIdToDie,queueElemAddr->id); + msgQueueElemClose(queueElemAddr); + + if (shm_unlink(queueElemId) < 0){ + NZG_ERROR("shm_unlink msgQueueElem",queueElemId); + goto ERROR; + } + if (nextIdToDie != NULL){ return msgQueueElemDelete(nextIdToDie); } else { diff --git a/src/queueElemDelete.c b/src/queueElemDelete.c index 8af618d..9fb4a9c 100644 --- a/src/queueElemDelete.c +++ b/src/queueElemDelete.c @@ -5,7 +5,16 @@ int msgQueueElemDelete(msgQueueElemId queueElemId){ msgQueueElemId nextIdToDie; queueElemAddr = msgQueueElemOpen(queueElemId); - msgQueueElemClose(queueElem); + if (queueElemAddr==NULL){ + NZG_ERROR("msgQueueElemOpen",queueElemId); + goto ERROR; + } + + if (msgQueueElemClose(queueElemAddr) < 0){ + NZG_ERROR("msgQueueElemClose",queueElemId); + goto ERROR; + } + if (nextIdToDie != NULL){ return msgQueueElemDelete(nextIdToDie); } else { diff --git a/src/queueOpen.c b/src/queueOpen.c index 2493a85..514a620 100644 --- a/src/queueOpen.c +++ b/src/queueOpen.c @@ -1,7 +1,7 @@ #include "libnazgul.h" #include "ids.h" -void * queueOpen(msgQueueId queueId){ +void * msgQueueOpen(msgQueueId queueId){ int queueFd; void * queueAddr;