l3.libnazgul/src/get.c

45 lines
1.1 KiB
C
Raw Normal View History

2004-02-24 10:25:19 +00:00
#include "libnazgul.h"
#define NONBLOCK -1
void * msgGet(msgSpace * space,int queueIndex,int option){
void * resultAddr;
// on teste la possibilit<69> 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);
2004-02-24 10:34:06 +00:00
msgQueueId queueId;
msgQueue * queue;
msgQueueIdIntern(queueId,space->externId,queueIndex);
// ouvrir la file
queue = msgQueueOpen(queueId);
2004-02-24 10:47:00 +00:00
msgQueueElemId oldElemId;
2004-02-24 10:34:06 +00:00
// recup<75>rer l'id de l'ancien element...
2004-02-24 10:47:15 +00:00
msgQueueRem(queue, oldElemId);
2004-02-24 10:34:06 +00:00
2004-02-24 10:47:15 +00:00
msgQueueElem * oldElem;
oldElem = msgQueueElemOpen(oldElemId);
2004-02-24 10:34:06 +00:00
// fermer la file
msgQueueClose(queue);
2004-02-24 10:25:19 +00:00
// on a fini de modifier la liste
msgQueueProtUnlock(space->externId,queueIndex);
return resultAddr;
ERROR:
return NULL;
}