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

32 lines
627 B
C

#include "libnazgul.h"
#include "ids.h"
int msgQueueProtUnlock(msgSpaceId externId,int queueIdx){
sem_t * queueSemFd;
msgQueueSemId queueSemId;
msgQueueProtSemIdIntern(queueSemId,externId,queueIdx);
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;
}
int semval=0;
sem_getvalue(queueSemFd,&semval);
printf("(AfterValue:%d)\n",semval);
sem_close(queueSemFd);
return 0;
ERROR:
return -1;
}