From a82a3e92a226c4accc59283110d6904d3653a580 Mon Sep 17 00:00:00 2001 From: glenux Date: Mon, 23 Feb 2004 19:07:40 +0000 Subject: [PATCH] *** empty log message *** --- src/queueLock.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/queueLock.c b/src/queueLock.c index 879af78..2c18bfe 100644 --- a/src/queueLock.c +++ b/src/queueLock.c @@ -1,14 +1,25 @@ #include "libnazgul.h" -int queueLock(msgSpaceId spaceid,int queueIdx){ +int queueLock(msgSpaceId externId,int queueIdx){ sem_t * queueSemFd; msgQueueSemId queueSemId; - queueSemFd=sem_open(queueSemId,O_CREAT|O_EXCL,0666,1); + msgQueueSemIdIntern(queueSemId,externId); + queueSemFd=sem_open(queueSemId,O_CREAT|O_EXCL,SEM_DEFAULT_MODE,1); if(queueSemFd==SEM_FAILED){ - NZG_ERROR("sem_open",queueSemId); - return -1; - } - return -1; + 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; }