l3.libnazgul/src/put.c

58 lines
1.3 KiB
C
Raw Normal View History

2004-02-23 23:25:11 +00:00
#include "libnazgul.h"
int msgPut(msgSpace * space,int queueIndex, void * addr){
// retrouver le pool, buffer qui correspondent <20> l'addresse...
msgPoolData * poolDataTabAddr;
int poolIndex;
int bufferIndex;
int err;
msgPoolDataTabLock(space);
poolDataTabAddr=msgPoolDataTabOpen(space);
err=msgBufferGetProcAttach(
poolDataTabAddr,
space->poolNb,
&poolIndex,
&bufferIndex,
addr
);
// ouvrir la queue avec le bon index
msgQueueId queueId;
msgQueue * queue;
msgQueueIdIntern(queueId,space->externId,queueIndex);
2004-02-24 09:43:56 +00:00
msgQueueProtLock(space->externId,queueIndex);
2004-02-23 23:25:11 +00:00
queue = msgQueueOpen(queueId);
// TODO:creer un element vide
msgQueueElemId newElemId;
msgQueueElem * queueElem;
msgQueueElemCreate(newElemId,queueId,queue->elemCounter);
// ouvrir l'element
queueElem=msgQueueElemOpen(newElemId);
// modifier les index pour retrouver le buffer
queueElem->poolIndex=poolIndex;
queueElem->bufferIndex=bufferIndex;
// fermer l'element
msgQueueElemClose(queueElem);
//ajouter le message a la bonne file...
msgQueueElemAdd(queue,newElemId);
// fermer la file
msgQueueClose(queue);
2004-02-24 09:43:56 +00:00
msgQueueProtUnlock(space->externId,queueIndex);
2004-02-23 23:25:11 +00:00
msgPoolDataTabClose(space,poolDataTabAddr);
/* msgPoolDataTabUnlock(space->id);
*/
2004-02-24 09:43:56 +00:00
msgQueueReadUnlock(space->externId,queueIndex);
2004-02-23 23:25:11 +00:00
return 0;
ERROR:
return -1;
}