26 lines
504 B
C
26 lines
504 B
C
#include "libnazgul.h"
|
|
#include "ids.h"
|
|
|
|
int msgQueueProtLock(msgSpaceId externId,int queueIdx){
|
|
sem_t * queueSemFd;
|
|
msgQueueSemId queueSemId;
|
|
|
|
msgQueueProtSemIdIntern(queueSemId,externId,queueIdx);
|
|
queueSemFd=sem_open(queueSemId,O_CREAT|O_EXCL,SEM_DEFAULT_MODE,1);
|
|
if(queueSemFd==SEM_FAILED){
|
|
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;
|
|
}
|
|
|