l3.libnazgul/src/queueDelete.c
2020-03-03 23:46:32 +01:00

28 lines
517 B
C

#include "libnazgul.h"
int msgQueueElemDelete(msgQueueElemId queueElemId){
msgQueueElem * queueElemAddr;
msgQueueElemId nextIdToDie;
queueElemAddr = msgQueueElemOpen(queueElemId);
strcpy(nextIdToDie,queueElemAddr->id);
msgQueueElemClose(queueElemAddr);
if (shm_unlink(queueElemId) < 0){
NZG_ERROR("shm_unlink msgQueueElem",queueElemId);
goto ERROR;
}
if (strcmp(nextIdToDie,queueElemId)==0){
return 0;
} else {
return msgQueueElemDelete(nextIdToDie);
}
ERROR:
return -1;
}