#include "libnazgul.h" int msgPut(msgSpace * space, int queueIndex, void *addr) { // retrouver le pool, buffer qui correspondent à l'addresse... msgPoolData *poolDataTabAddr; int poolIndex; int bufferIndex; int err; msgQueueElemId newElemId; msgQueueElem *queueElem; msgQueueId queueId; msgQueue *queue; msgPoolDataTabLock(space); poolDataTabAddr = msgPoolDataTabOpen(space); if (poolDataTabAddr == NULL) { NZG_ERROR("msgPoolDataTabOpen", space->poolDataTabId); goto ERROR; } err = msgBufferGetProcAttach(poolDataTabAddr, space->poolNb, &poolIndex, &bufferIndex, addr); if (err) { //FIXME } // ouvrir la queue avec le bon index msgQueueIdIntern(queueId, space->externId, queueIndex); msgQueueProtLock(space->externId, queueIndex); queue = msgQueueOpen(queueId); // creer un element vide 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 if (msgQueueElemClose(queueElem) < 0) { NZG_ERROR("msgQueueElemClose", ""); goto ERROR; } //ajouter le message a la bonne file... if (msgQueueAdd(queue, newElemId) < 0) { NZG_ERROR("msgQueueAdd", newElemId); goto ERROR; } // 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; ERROR: return -1; }