*** empty log message ***

This commit is contained in:
glenux 2004-02-23 16:22:44 +00:00
parent 1a39b8e7f2
commit 4994b51568
3 changed files with 25 additions and 14 deletions

View file

@ -183,19 +183,24 @@ void * msgAllocate(msgSpace *space,
return NULL;
}
printf("Buffer selected : %d,%d\n",selectedPoolIndex,bufferFreeIndex);
/* mapper le buffer libre dans l'esp addr du proc */
strcpy(resultPoolId,mSPoolDataTabAddr[selectedPoolIndex].poolId);
mSPoolFd=shm_open(resultPoolId,O_RDWR,MSGSPACE_DEFAULT_MODE);
int bufferFreeSize=mSPoolDataTabAddr[selectedPoolIndex].bufferSize;
resultAddr = mmap( 0,
bufferFreeSize,
int bufferFreeSize;
bufferFreeSize=mSPoolDataTabAddr[selectedPoolIndex].bufferSize;
printf("BufferSize : %d", bufferFreeSize);
resultAddr = mmap( NULL,
bufferFreeSize,
PROT_READ | PROT_WRITE,
MAP_SHARED, mSPoolFd, bufferFreeSize*bufferFreeIndex );
MAP_SHARED, mSPoolFd,
(off_t)0); // bufferFreeSize*bufferFreeIndex );
if( resultAddr == MAP_FAILED) {
NZG_ERROR("resultAddr mmap","");
goto ERROR;
}
//TODO:
/* - on s'enregistre aupres de ce buffer */
@ -209,7 +214,13 @@ void * msgAllocate(msgSpace *space,
sem_close(poolDataTabSemFd);
/* unmapper le msgPoolDataTab */
munmap(mSPoolDataTabAddr,(space->poolNb) * sizeof( msgPoolData ));
munmap(mSPoolDataTabAddr,(space->poolNb) * sizeof( msgPoolData ));
printf( "alloc de 0x%08x\n", (int)resultAddr);
return resultAddr;
ERROR:
NZG_ERROR("msgAllocate","error processing");
sem_post(poolDataTabSemFd);
sem_close(poolDataTabSemFd);
munmap(mSPoolDataTabAddr,(space->poolNb) * sizeof( msgPoolData ));
return NULL;
}

View file

@ -1,6 +1,7 @@
#include "libnazgul.h"
int msgFree(msgSpace * space, void * addr){
printf("Freeee de :0x%08x\n",(int)addr);
int poolIndex;
int bufferIndex;
@ -20,8 +21,6 @@ sem_t * poolDataTabSemFd;
}
sem_wait(poolDataTabSemFd);
/* verifier le premier arg du shm_open */
poolDataTabFd=shm_open(space->poolDataTabId,
@ -35,7 +34,7 @@ sem_t * poolDataTabSemFd;
}
poolDataTabAddr = mmap( 0, (space->poolNb) * sizeof( msgPoolData ),
poolDataTabAddr = mmap( NULL, (space->poolNb) * sizeof( msgPoolData ),
PROT_READ | PROT_WRITE,
MAP_SHARED, poolDataTabFd, 0 );
@ -49,6 +48,7 @@ sem_t * poolDataTabSemFd;
// TODO: verouiller semaphore DataInfo
int err;
printf("FREE-SEMWAIT\n");
err=msgBufferGetProcAttach(
poolDataTabAddr,
space->poolNb,
@ -81,6 +81,6 @@ sem_t * poolDataTabSemFd;
//sem_open ressource
//sem_post
//sem_close
return -1;
return 0;
}

View file

@ -15,7 +15,7 @@ int main(void) {
poolInfos[1].bufferNb=5;
poolInfos[1].bufferSize=250;
poolInfos[2].bufferNb=6;
poolInfos[2].bufferNb=5;
poolInfos[2].bufferSize=280;
strcpy(testId,"test");
@ -43,7 +43,7 @@ int main(void) {
montext=msgAllocate(mSPAC,2,270,0);
sleep(2);
montext=msgAllocate(mSPAC,2,270,0);
//msgFree(mSPAC,(void *)montext);
msgFree(mSPAC,(void *)montext);
//msgFree(mSPAC,(void *)montext);
//msgFree(mSPAC,(void *)montext);
wait(NULL);