From 27b4accdd9a6ef77c12a810fa5766afab07300ed Mon Sep 17 00:00:00 2001 From: glenux Date: Mon, 23 Feb 2004 17:15:20 +0000 Subject: [PATCH] *** empty log message *** --- src/nzg_allocate.c | 12 ++++++++++-- src/nzg_bufferDetachProc.c | 3 ++- src/nzg_free.c | 5 ++--- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/nzg_allocate.c b/src/nzg_allocate.c index 7367a20..16d8e7e 100644 --- a/src/nzg_allocate.c +++ b/src/nzg_allocate.c @@ -192,11 +192,19 @@ void * msgAllocate(msgSpace *space, int bufferFreeSize; bufferFreeSize=mSPoolDataTabAddr[selectedPoolIndex].bufferSize; printf("BufferSize : %d", bufferFreeSize); - resultAddr = mmap( NULL, + + // on mappe la totalité du pool + resultAddr = mmap( NULL, bufferFreeSize, PROT_READ | PROT_WRITE, MAP_SHARED, mSPoolFd, - (off_t)0); // bufferFreeSize*bufferFreeIndex ); + (off_t)0); + int bufferNb=mSPoolDataTabAddr[selectedPoolIndex].bufferNb; + + mprotect(resultAddr,bufferFreeSize*bufferNb,PROT_NONE); + mprotect(resultAddr,bufferFreeSize*(bufferFreeIndex+1),PROT_READ|PROT_WRITE); + + //(bufferFreeSize*bufferFreeIndex) ); if( resultAddr == MAP_FAILED) { NZG_ERROR("resultAddr mmap",""); goto ERROR; diff --git a/src/nzg_bufferDetachProc.c b/src/nzg_bufferDetachProc.c index 8ec4949..2572eed 100644 --- a/src/nzg_bufferDetachProc.c +++ b/src/nzg_bufferDetachProc.c @@ -11,6 +11,7 @@ int msgBufferDetachProc( msgBufferInfo * bufferInfoTabAddr; int bufferInfoNb; + printf("Detaching %d,%d\n",poolIndex,bufferIndex); //récuperer l'ID du BufferInfoTab; strcpy(bufferInfoTabId, poolDataTabAddr[poolIndex].bufferInfoTabId); @@ -23,7 +24,7 @@ int msgBufferDetachProc( /** on regarde dans le tableau d'infos de buffer **/ bufferInfoNb=poolDataTabAddr[poolIndex].bufferNb; bufferInfoTabAddr=mmap(NULL,bufferInfoNb*sizeof(msgBufferInfo), - PROT_READ,MAP_SHARED,bufferInfoTabFd,(off_t)0); + PROT_READ|PROT_WRITE,MAP_SHARED,bufferInfoTabFd,(off_t)0); bufferInfoTabAddr[bufferIndex].ownerPid = (pid_t)-1; bufferInfoTabAddr[bufferIndex].addr = NULL; diff --git a/src/nzg_free.c b/src/nzg_free.c index e58eb2b..ae51825 100644 --- a/src/nzg_free.c +++ b/src/nzg_free.c @@ -1,7 +1,7 @@ #include "libnazgul.h" int msgFree(msgSpace * space, void * addr){ - printf("Freeee de :0x%08x\n",(int)addr); + printf("[ FREE 0x%08x ]\n",(int)addr); int poolIndex; int bufferIndex; @@ -59,8 +59,7 @@ sem_t * poolDataTabSemFd; printf("Found : %d\n",err); printf("Freing pool: %d, buffer: %d\n",poolIndex,bufferIndex); - //msgBufferDetachProc(poolDataTabAddr,poolIndex,bufferIndex,addr); - printf("FREE-SEMWAIT\n"); + msgBufferDetachProc(poolDataTabAddr,poolIndex,bufferIndex,addr); /* unmapper le msgPoolDataTab */ munmap(poolDataTabAddr,(space->poolNb) * sizeof( msgPoolData ));