l3.libnazgul/src/put.c

71 lines
1.6 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){
2004-02-24 09:54:05 +00:00
// retrouver le pool, buffer qui correspondent <20> l'addresse...
2004-02-23 23:25:11 +00:00
msgPoolData * poolDataTabAddr;
2004-02-24 09:54:05 +00:00
int poolIndex;
int bufferIndex;
int err;
2004-02-25 11:12:03 +00:00
msgQueueElemId newElemId;
msgQueueElem * queueElem;
2004-02-23 23:25:11 +00:00
msgPoolDataTabLock(space);
poolDataTabAddr=msgPoolDataTabOpen(space);
2004-02-25 10:32:41 +00:00
if (poolDataTabAddr == NULL){
NZG_ERROR("msgPoolDataTabOpen",space->poolDataTabId);
goto ERROR;
}
2004-02-24 09:54:05 +00:00
err=msgBufferGetProcAttach(
2004-02-23 23:25:11 +00:00
poolDataTabAddr,
space->poolNb,
&poolIndex,
&bufferIndex,
addr
);
2004-02-24 09:54:05 +00:00
// ouvrir la queue avec le bon index
msgQueueId queueId;
msgQueue * queue;
msgQueueIdIntern(queueId,space->externId,queueIndex);
2004-02-25 08:08:31 +00:00
2004-02-24 09:54:05 +00:00
msgQueueProtLock(space->externId,queueIndex);
queue = msgQueueOpen(queueId);
2004-02-25 11:12:03 +00:00
// creer un element vide
2004-02-24 09:54:05 +00:00
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
2004-02-25 08:53:54 +00:00
if (msgQueueElemClose(queueElem) <0 ){
NZG_ERROR("msgQueueElemClose","");
goto ERROR;
}
2004-02-24 09:54:05 +00:00
//ajouter le message a la bonne file...
2004-02-25 11:34:49 +00:00
if (msgQueueAdd(queue,newElemId) < 0){
2004-02-25 11:44:41 +00:00
NZG_ERROR("msgQueueAdd",newElemId);
2004-02-25 08:53:54 +00:00
goto ERROR;
}
2004-02-24 09:54:05 +00:00
// fermer la file
msgQueueClose(queue);
msgQueueProtUnlock(space->externId,queueIndex);
msgPoolDataTabClose(space,poolDataTabAddr);
msgPoolDataTabUnlock(space);
// on laisse une nouvelle ressource de la liste au get
msgQueueReadUnlock(space->externId,queueIndex);
return 0;
2004-02-23 23:25:11 +00:00
ERROR:
2004-02-24 09:54:05 +00:00
return -1;
2004-02-23 23:25:11 +00:00
}