*** empty log message ***

This commit is contained in:
glenux 2004-02-21 21:07:40 +00:00 committed by Glenn Y. Rolland
parent c7a7897184
commit 9fae54021e
5 changed files with 42 additions and 28 deletions

View file

@ -26,9 +26,9 @@ int msgPoolSemIdIntern(
}
/* sprintf(resNzgId,"/tmp/.nzg-%s",(char *)spaceId); */
#ifdef _NZG_REALFILEID
sprintf(destSemId,"/tmp/nzgPoolSem%s-%d",(char *)srcPoolId,poolIdx);
sprintf(destSemId,"/tmp/nzgPoolSem-%s-%d",(char *)srcPoolId,poolIdx);
#else
sprintf(destSemId,"/nzgPoolSem%s-%d",(char *)srcPoolId,poolIdx);
sprintf(destSemId,"/nzgPoolSem-%s-%d",(char *)srcPoolId,poolIdx);
#endif
return 0;
}
@ -39,22 +39,22 @@ int msgPoolDataIdIntern(msgPoolDataTabId dest,const msgSpaceId src ){
}
/* sprintf(resNzgId,"/tmp/.nzg-%s",(char *)spaceId); */
#ifdef _NZG_REALFILEID
sprintf(dest,"/tmp/nzgPoolData%s",(char *)src);
sprintf(dest,"/tmp/nzgPoolData-%s",(char *)src);
#else
sprintf(dest,"/nzgPoolData%s",(char *)src);
sprintf(dest,"/nzgPoolData-%s",(char *)src);
#endif
return 0;
}
int msgSpacePoolId2nzgPoolId(msgPoolId dest,msgPoolId src, int num){
int msgPoolIdIntern(msgPoolId dest,msgPoolId src, int num){
if (strlen(src)>MSGSPACE_ID_LEN){
return -1;
}
#ifdef _NZG_REALFILEID
sprintf(dest,"/tmp/nzgPool%s%d",(char *)src,num);
sprintf(dest,"/tmp/nzgPool-%s-%d",(char *)src,num);
#else
sprintf(dest,"/nzgPool%s%d",(char *)src,num);
sprintf(dest,"/nzgPool-%s-%d",(char *)src,num);
#endif
return 0;
}

View file

@ -8,7 +8,7 @@
int msgSpaceIdIntern(msgSpaceId dest, const msgSpaceId src);
int msgPoolSemIdIntern(msgPoolSemId destSemId, const msgSpaceId srcPoolId, int poolIdx);
int msgPoolDataIdIntern(msgPoolDataTabId dest, const msgSpaceId src);
int msgSpacePoolId2nzgPoolId(msgPoolId dest, msgPoolId src, int num);
int msgPoolIdIntern(msgPoolId dest,msgPoolId src, int num);
#endif

View file

@ -5,31 +5,37 @@
liste process demandeurs */
int msgPoolCreate(
msgPoolId poolId,
msgSpaceId spaceId,
int poolIdx,
int buffNb,
int buffSize
) {
int poolFd;
static int poolNb;
msgPoolId id;
sem_t * sem;
if (msgSpacePoolId2nzgPoolId(id,poolId,poolNb) == -1){
msgPoolId poolId;
msgPoolSemId poolSemId;
if (msgPoolIdIntern(poolId,spaceId,poolIdx) == -1){
fprintf( stderr, "msgPoolId creation failed for id %s\n",
(char*)poolId );
return -1;
}
poolFd=shm_open(id,O_RDWR|O_CREAT|O_EXCL|O_TRUNC,MSGSPACE_DEFAULT_MODE);
poolFd=shm_open(poolId,O_RDWR|O_CREAT|O_EXCL|O_TRUNC,MSGSPACE_DEFAULT_MODE);
if (poolFd == -1 ) {
fprintf( stderr, "msgPool creation failed: %s\n",
fprintf( stderr, "msgPool : %s creation failed: %s\n",poolId,
strerror( errno ) );
return -1;
}
if (msgPoolSemIdIntern(poolSemId,spaceId,poolIdx) == -1){
fprintf( stderr, "msgPoolId creation failed for id %s\n",
(char*)poolSemId );
return -1;
}
// on met un semaphore sur le pool
sem = sem_open(id, O_CREAT|O_EXCL, 0666, buffNb);
sem = sem_open(poolSemId, O_CREAT|O_EXCL, 0666, buffNb);
// on met le pool a la taille voulue pour qu'il
// puisse contenir les buffs

View file

@ -1,16 +1,18 @@
#ifndef _NZG_PROTO
#define _NZG_PROTO 1
/* nzg_list.c */
/* msgSpaceListId msgSpaceIdList(void); */
/* nzg_pool.c */
int msgPoolCreate(msgPoolId poolId, int buffNb, int buffSize);
int msgSpacePoolId2nzgPoolId(msgPoolId dest, msgPoolId src, int num);
/* nzg_spaces.c */
msgSpace *msgSpaceCreate(msgSpaceId spaceId, int queueNb, int poolNb, msgPool *queueNbCar);
/* src/nzg_allocate.c */
void *msgAllocate(msgSpace *space, int pool, int taille, int option);
/* src/nzg_list.c */
/* src/nzg_msgList.c */
msgSpaceListElem *addBegining(msgSpaceListElem *list, int ownerpid);
/* src/nzg_pool.c */
int msgPoolCreate(msgSpaceId spaceId, int poolIdx, int buffNb, int buffSize);
/* src/nzg_spaces.c */
msgSpace *msgSpaceCreate(msgSpaceId spaceId, int queueNb, int poolNb, msgPool *poolInfos);
msgSpace *msgSpaceOpen(msgSpaceId spaceId);
int msgSpaceDelete(msgSpaceId spaceId);
/* nzg_state.c */
/* src/nzg_state.c */
#endif

View file

@ -127,9 +127,14 @@ msgSpace * msgSpaceCreate(
mSPoolDataAddr[i].bufferNb=poolInfos[i].bufferNb;
mSPoolDataAddr[i].bufferSize=poolInfos[i].bufferSize;
mSPoolDataAddr[i].allocDispBuffer=0;
msgPoolId poolId;
msgPoolCreate(poolId,poolInfos[i].bufferNb,poolInfos[i].bufferSize);
if (msgPoolIdIntern(poolId,spaceId,i) == -1){
fprintf( stderr, "msgPoolId creation failed for id %s\n",
(char*)poolId );
return NULL;
}
msgPoolCreate(spaceId,i,poolInfos[i].bufferNb,poolInfos[i].bufferSize);
strcpy(mSPoolDataAddr[i].id,poolId);
}
@ -172,7 +177,8 @@ int msgSpaceDelete(msgSpaceId spaceId){
}
space = msgSpaceOpen(spaceId);
/* TODO: supprimer chaque pool */
printf("openned successfully !\n");
printf("Unlinking DataTab... ");
if (shm_unlink(space->poolDataTabId) < 0){