l3.libnazgul/src/bufferInfoTabInit.c

35 lines
1,010 B
C
Raw Normal View History

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;
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;
}