l3.libnazgul/src/poolDataTabLock.c

33 lines
624 B
C
Raw Normal View History

2004-02-23 23:25:11 +00:00
#include "libnazgul.h"
#include "ids.h"
int msgPoolDataTabLock(msgSpace * space){
sem_t * poolDataTabSemFd;
2004-02-25 11:12:03 +00:00
printf("Locking %s\n",space->poolDataTabSemId);
2004-02-23 23:25:11 +00:00
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;
}
2004-02-25 11:12:03 +00:00
int semval=0;
sem_getvalue(poolDataTabSemFd,&semval);
printf("(AfternValue:%d)\n",semval);
2004-02-23 23:25:11 +00:00
sem_close(poolDataTabSemFd);
return 0;
ERROR:
return -1;
}