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

32 lines
624 B
C

#include "libnazgul.h"
#include "ids.h"
int msgPoolDataTabLock(msgSpace * space){
sem_t * poolDataTabSemFd;
printf("Locking %s\n",space->poolDataTabSemId);
poolDataTabSemFd=sem_open(
space->poolDataTabSemId
,O_CREAT,
SEM_DEFAULT_MODE,
1);
if(poolDataTabSemFd==SEM_FAILED){
NZG_ERROR("sem_open",space->poolDataTabSemId);
goto ERROR;
}
if(sem_wait(poolDataTabSemFd)==-1){
NZG_ERROR("sem_wait",space->poolDataTabSemId);
goto ERROR;
}
int semval=0;
sem_getvalue(poolDataTabSemFd,&semval);
printf("(AfternValue:%d)\n",semval);
sem_close(poolDataTabSemFd);
return 0;
ERROR:
return -1;
}