*** empty log message ***

This commit is contained in:
glenux 2004-02-23 23:25:11 +00:00 committed by Glenn Y. Rolland
parent 65e3532430
commit 7a2398e8d4
5 changed files with 126 additions and 0 deletions

13
src/poolDataTabClose.c Normal file
View file

@ -0,0 +1,13 @@
#include "libnazgul.h"
int msgPoolDataTabClose(msgSpace * space,void * addr){
/* unmapper le msgPoolDataTab */
if (munmap(addr,(space->poolNb) * sizeof( msgPoolData )) < 0){
NZG_ERROR("unmap",space->poolDataTabId);
goto ERROR;
}
return 0;
ERROR:
return -1;
}

28
src/poolDataTabLock.c Normal file
View file

@ -0,0 +1,28 @@
#include "libnazgul.h"
#include "ids.h"
int msgPoolDataTabLock(msgSpace * space){
sem_t * poolDataTabSemFd;
poolDataTabSemFd=sem_open(
space->poolDataTabSemId
,O_CREAT,
SEM_DEFAULT_MODE,
1);
if(poolDataTabSemFd==SEM_FAILED){
NZG_ERROR("sem_open",space->poolDataTabSemId);
goto ERROR;
}
if(sem_wait(poolDataTabSemFd)==-1){
NZG_ERROR("sem_wait",space->poolDataTabSemId);
goto ERROR;
}
sem_close(poolDataTabSemFd);
return 0;
ERROR:
return -1;
}

31
src/poolDataTabOpen.c Normal file
View file

@ -0,0 +1,31 @@
#include "libnazgul.h"
#include "ids.h"
void * msgPoolDataTabOpen(msgSpace * space){
int poolDataTabFd;
void * poolDataTabAddr;
poolDataTabFd=shm_open(space->poolDataTabId,
O_RDWR,
MSGSPACE_DEFAULT_MODE);
if (poolDataTabFd == -1 ) {
NZG_ERROR("shm_open",space->poolDataTabId);
goto ERROR;
}
poolDataTabAddr = mmap( NULL, (space->poolNb) * sizeof( msgPoolData ),
PROT_READ | PROT_WRITE,
MAP_SHARED, poolDataTabFd, 0 );
if( poolDataTabAddr == MAP_FAILED) {
NZG_ERROR("mmap",space->poolDataTabId);
goto ERROR;
}
close(poolDataTabFd);
return poolDataTabAddr;
ERROR:
return NULL;
}

0
src/poolDataTabUnlock.c Normal file
View file

54
src/put.c Normal file
View file

@ -0,0 +1,54 @@
#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;
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);
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);
msgPoolDataTabClose(space,poolDataTabAddr);
/* msgPoolDataTabUnlock(space->id);
*/
return 0;
ERROR:
return -1;
}