l3.libnazgul/src/queueReadUnlock.c

38 lines
701 B
C
Raw Normal View History

2004-02-24 09:31:11 +00:00
#include "libnazgul.h"
#include "ids.h"
#define DEBUG 0
2020-03-03 23:06:43 +00:00
int msgQueueReadUnlock(msgSpaceId externId, int queueIdx)
{
int semval;
sem_t *queueSemFd;
msgQueueSemId queueSemId;
msgQueueReadSemIdIntern(queueSemId, externId, queueIdx);
if (DEBUG) {
printf("Unlocking %s\n", queueSemId);
}
queueSemFd = sem_open(queueSemId, O_CREAT, SEM_DEFAULT_MODE, 1);
if (queueSemFd == SEM_FAILED) {
NZG_ERROR("sem_open", queueSemId);
goto ERROR;
}
if (sem_post(queueSemFd) == -1) {
NZG_ERROR("sem_post", queueSemId);
goto ERROR;
}
semval = 0;
sem_getvalue(queueSemFd, &semval);
if (DEBUG) {
printf("(AfterValue:%d)\n", semval);
}
sem_close(queueSemFd);
return 0;
ERROR:
return -1;
2004-02-24 09:31:11 +00:00
}