2004-02-23 20:37:08 +00:00
|
|
|
#include "libnazgul.h"
|
|
|
|
|
2020-03-03 23:06:43 +00:00
|
|
|
int msgQueueDelete(msgQueueId externId, int queueIdx)
|
|
|
|
{
|
|
|
|
msgQueue *queue;
|
|
|
|
msgQueueId queueId;
|
|
|
|
msgQueueSemId queueProtLockSemId;
|
|
|
|
msgQueueSemId queueReadLockSemId;
|
2019-09-17 12:49:28 +00:00
|
|
|
|
2020-03-03 23:06:43 +00:00
|
|
|
msgQueueIdIntern(queueId, externId, queueIdx);
|
|
|
|
queue = msgQueueOpen(queueId);
|
2004-02-23 20:37:08 +00:00
|
|
|
|
2020-03-03 23:06:43 +00:00
|
|
|
if (strcmp(queue->headId, queue->id) != 0) {
|
|
|
|
// liste non-vide
|
|
|
|
if (msgQueueElemDelete(queue->headId) < 0) {
|
|
|
|
NZG_ERROR("msgQueueElemDelete", queue->headId);
|
|
|
|
goto ERROR;
|
|
|
|
}
|
|
|
|
}
|
2004-02-23 22:34:28 +00:00
|
|
|
|
2020-03-03 23:06:43 +00:00
|
|
|
msgQueueProtSemIdIntern(queueProtLockSemId, externId, queueIdx);
|
|
|
|
msgQueueReadSemIdIntern(queueReadLockSemId, externId, queueIdx);
|
|
|
|
sem_unlink(queueProtLockSemId);
|
|
|
|
sem_unlink(queueReadLockSemId);
|
2004-02-23 20:37:08 +00:00
|
|
|
|
2020-03-03 23:06:43 +00:00
|
|
|
if (shm_unlink(queueId) < 0) {
|
|
|
|
NZG_ERROR("shm_unlink msgQueueElem", queueId);
|
|
|
|
goto ERROR;
|
|
|
|
}
|
2004-02-23 20:37:08 +00:00
|
|
|
|
2020-03-03 23:06:43 +00:00
|
|
|
return 0;
|
|
|
|
ERROR:
|
|
|
|
return -1;
|
|
|
|
}
|