l3.libnazgul/src/queueProtLock.c

27 lines
504 B
C
Raw Normal View History

2004-02-23 18:50:52 +00:00
#include "libnazgul.h"
2004-02-23 20:00:06 +00:00
#include "ids.h"
2004-02-23 18:50:52 +00:00
2004-02-24 09:43:56 +00:00
int msgQueueProtLock(msgSpaceId externId,int queueIdx){
2004-02-23 18:50:52 +00:00
sem_t * queueSemFd;
msgQueueSemId queueSemId;
2004-02-24 09:31:11 +00:00
msgQueueProtSemIdIntern(queueSemId,externId,queueIdx);
2004-02-23 19:07:40 +00:00
queueSemFd=sem_open(queueSemId,O_CREAT|O_EXCL,SEM_DEFAULT_MODE,1);
2004-02-23 18:50:52 +00:00
if(queueSemFd==SEM_FAILED){
2004-02-23 19:07:40 +00:00
NZG_ERROR("sem_open",queueSemId);
goto ERROR;
}
if(sem_wait(queueSemFd)==-1){
NZG_ERROR("sem_wait",queueSemId);
goto ERROR;
}
sem_close(queueSemFd);
return 0;
ERROR:
return -1;
2004-02-23 18:50:52 +00:00
}