*** empty log message ***
This commit is contained in:
parent
27b4accdd9
commit
639a56ac4b
2 changed files with 53 additions and 1 deletions
|
@ -203,8 +203,10 @@ void * msgAllocate(msgSpace *space,
|
|||
|
||||
mprotect(resultAddr,bufferFreeSize*bufferNb,PROT_NONE);
|
||||
mprotect(resultAddr,bufferFreeSize*(bufferFreeIndex+1),PROT_READ|PROT_WRITE);
|
||||
mprotect(resultAddr,bufferFreeSize*bufferFreeIndex,PROT_NONE);
|
||||
resultAddr=resultAddr +( bufferFreeSize*bufferFreeIndex);
|
||||
strcpy(resultAddr,"a");
|
||||
|
||||
//(bufferFreeSize*bufferFreeIndex) );
|
||||
if( resultAddr == MAP_FAILED) {
|
||||
NZG_ERROR("resultAddr mmap","");
|
||||
goto ERROR;
|
||||
|
|
50
src/nzg_bufferGetProcAttach.c
Normal file
50
src/nzg_bufferGetProcAttach.c
Normal file
|
@ -0,0 +1,50 @@
|
|||
#include "libnazgul.h"
|
||||
|
||||
int msgBufferGetProcAttach(
|
||||
msgPoolData * poolDataTabAddr,
|
||||
int poolNb,
|
||||
int * poolIndex,
|
||||
int * bufferIndex,
|
||||
void * addr
|
||||
){
|
||||
msgBufferInfoTabId bufferInfoTabId;
|
||||
int bufferInfoTabFd;
|
||||
msgBufferInfo * bufferInfoTabAddr;
|
||||
int bufferInfoNb;
|
||||
|
||||
bool found=false;
|
||||
int pIdx=0;
|
||||
while ((!found) && (pIdx < poolNb)){
|
||||
/* Pour chaque pool */
|
||||
//récuperer l'ID du BufferInfoTab;
|
||||
strcpy(bufferInfoTabId, poolDataTabAddr[pIdx].bufferInfoTabId);
|
||||
bufferInfoNb=poolDataTabAddr[pIdx].bufferNb;
|
||||
|
||||
bufferInfoTabFd=shm_open(bufferInfoTabId,O_RDWR,SHM_DEFAULT_MODE);
|
||||
if (bufferInfoTabFd<0)
|
||||
{ NZG_ERROR("shm_open",bufferInfoTabId); return -1; }
|
||||
|
||||
/** on regarde dans le tableau d'infos de buffer **/
|
||||
bufferInfoTabAddr=mmap(NULL,bufferInfoNb*sizeof(msgBufferInfo),
|
||||
PROT_READ,MAP_SHARED,bufferInfoTabFd,(off_t)0);
|
||||
|
||||
/* on cherche dans chacun des buffers */
|
||||
int bIdx=0;
|
||||
while((!found) && bIdx<bufferInfoNb){
|
||||
if (bufferInfoTabAddr[bIdx].addr == addr){
|
||||
found=true;
|
||||
(*bufferIndex)=bIdx;
|
||||
};
|
||||
bIdx++;
|
||||
}
|
||||
if (found){ (*poolIndex)=pIdx; }
|
||||
/* on détache le morceau de mémoire */
|
||||
if (munmap(bufferInfoTabAddr,bufferInfoNb*sizeof(msgBufferInfo))< 0)
|
||||
{ NZG_ERROR("munmap",bufferInfoTabId); return -1; }
|
||||
close(bufferInfoTabFd);
|
||||
pIdx++;
|
||||
}
|
||||
|
||||
if (found){ return 0; } else {return -1;}
|
||||
}
|
||||
|
Loading…
Reference in a new issue