From 7d5bed91a19251a89b9064373d7a6800920f49ea Mon Sep 17 00:00:00 2001 From: glenux Date: Tue, 24 Feb 2004 10:25:19 +0000 Subject: [PATCH] *** empty log message *** --- src/get.c | 29 +++++++++++++++++++++++++++++ src/proto.h | 4 ++++ 2 files changed, 33 insertions(+) diff --git a/src/get.c b/src/get.c index e69de29..6ced0a5 100644 --- a/src/get.c +++ b/src/get.c @@ -0,0 +1,29 @@ +#include "libnazgul.h" + +#define NONBLOCK -1 + +void * msgGet(msgSpace * space,int queueIndex,int option){ + void * resultAddr; + // on teste la possibilité de lecture sur la liste... + if (option == NONBLOCK){ + if (msgQueueReadTryLock(space->externId,queueIndex) <0){ + NZG_ERROR("msgQueueReadTryLock",space->externId); + goto ERROR; + } + } else { + if (msgQueueReadLock(space->externId,queueIndex) <0){ + NZG_ERROR("msgQueueReadLock",space->externId); + goto ERROR; + } + } + // la lecture est possible + // on essaye donc de modifier la liste + msgQueueProtLock(space->externId,queueIndex); + + // on a fini de modifier la liste + msgQueueProtUnlock(space->externId,queueIndex); + + return resultAddr; +ERROR: + return NULL; +} diff --git a/src/proto.h b/src/proto.h index aebea80..417f466 100644 --- a/src/proto.h +++ b/src/proto.h @@ -19,6 +19,8 @@ int msgBufferInfoTabCreate(msgSpaceId externId, msgPoolData *poolDataTabAddr, in int msgBufferInfoTabInit(msgPoolData *poolDataTabAddr, int poolIndex); /* free.c */ int msgFree(msgSpace *space, void *addr); +/* get.c */ +void *msgGet(msgSpace *space, int queueIndex, int option); /* ids.c */ int msgSpaceIdIntern(msgSpaceId dest, const msgSpaceId src); int msgPoolDataTabSemIdIntern(msgPoolSemId destSemId, const msgSpaceId externId); @@ -70,6 +72,8 @@ int msgQueueProtLock(msgSpaceId externId, int queueIdx); int msgQueueProtUnlock(msgSpaceId externId, int queueIdx); /* queueReadLock.c */ int msgQueueReadLock(msgSpaceId externId, int queueIdx); +/* queueReadTryLock.c */ +int msgQueueReadTryLock(msgSpaceId externId, int queueIdx); /* queueReadUnlock.c */ int msgQueueReadUnlock(msgSpaceId externId, int queueIdx); /* queueRem.c */