2004-02-22 14:26:54 +00:00
|
|
|
|
#include "libnazgul.h"
|
|
|
|
|
|
2004-02-22 15:29:36 +00:00
|
|
|
|
int msgBufferInfoTabInit(msgPoolData * poolDataTabAddr,int poolIndex){
|
2004-02-22 14:26:54 +00:00
|
|
|
|
msgBufferInfoTabId bufferInfoTabId;
|
|
|
|
|
int bufferInfoTabFd;
|
|
|
|
|
msgBufferInfo * bufferInfoTabAddr;
|
2004-02-23 11:23:11 +00:00
|
|
|
|
int bufferInfoNb;
|
|
|
|
|
int i;
|
2004-02-22 14:26:54 +00:00
|
|
|
|
|
|
|
|
|
//r<>cuperer l'ID du BufferInfoTab;
|
|
|
|
|
strcpy(bufferInfoTabId, poolDataTabAddr[poolIndex].bufferInfoTabId);
|
2004-02-22 15:29:36 +00:00
|
|
|
|
|
|
|
|
|
printf("msgBufferInfoTabId %d open >>%s<<\n",poolIndex,bufferInfoTabId);
|
2004-02-22 14:26:54 +00:00
|
|
|
|
bufferInfoTabFd=shm_open(bufferInfoTabId,O_RDWR,SHM_DEFAULT_MODE);
|
|
|
|
|
if (bufferInfoTabFd<0){
|
2004-02-22 15:29:36 +00:00
|
|
|
|
NZG_ERROR("msgBufferInfoTabId open",bufferInfoTabId);
|
2004-02-22 14:26:54 +00:00
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** on regarde dans le tableau d'infos de buffer **/
|
|
|
|
|
bufferInfoNb=poolDataTabAddr[poolIndex].bufferNb;
|
|
|
|
|
bufferInfoTabAddr=mmap(NULL,bufferInfoNb*sizeof(msgBufferInfo),
|
2004-02-22 15:29:36 +00:00
|
|
|
|
PROT_WRITE|PROT_READ,MAP_SHARED,bufferInfoTabFd,(off_t)0);
|
2004-02-22 14:26:54 +00:00
|
|
|
|
|
|
|
|
|
for (i=0;i<bufferInfoNb;i++){
|
|
|
|
|
bufferInfoTabAddr[i].ownerPid = (pid_t)-1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (munmap(bufferInfoTabAddr,bufferInfoNb*sizeof(msgBufferInfo))< 0)
|
|
|
|
|
{ perror("munmap"); return -1; }
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|