*** empty log message ***

This commit is contained in:
glenux 2004-02-21 21:07:40 +00:00
parent b54dc1c8ec
commit 9986f883a8
5 changed files with 42 additions and 28 deletions

View file

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

View file

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

View file

@ -5,31 +5,37 @@
liste process demandeurs */ liste process demandeurs */
int msgPoolCreate( int msgPoolCreate(
msgPoolId poolId, msgSpaceId spaceId,
int poolIdx,
int buffNb, int buffNb,
int buffSize int buffSize
) { ) {
int poolFd; int poolFd;
static int poolNb; static int poolNb;
msgPoolId id;
sem_t * sem; sem_t * sem;
msgPoolId poolId;
if (msgSpacePoolId2nzgPoolId(id,poolId,poolNb) == -1){ msgPoolSemId poolSemId;
if (msgPoolIdIntern(poolId,spaceId,poolIdx) == -1){
fprintf( stderr, "msgPoolId creation failed for id %s\n", fprintf( stderr, "msgPoolId creation failed for id %s\n",
(char*)poolId ); (char*)poolId );
return -1; 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 ) { if (poolFd == -1 ) {
fprintf( stderr, "msgPool creation failed: %s\n", fprintf( stderr, "msgPool : %s creation failed: %s\n",poolId,
strerror( errno ) ); strerror( errno ) );
return -1; 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 // 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 // on met le pool a la taille voulue pour qu'il
// puisse contenir les buffs // puisse contenir les buffs

View file

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

View file

@ -129,7 +129,12 @@ msgSpace * msgSpaceCreate(
mSPoolDataAddr[i].allocDispBuffer=0; mSPoolDataAddr[i].allocDispBuffer=0;
msgPoolId poolId; 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); strcpy(mSPoolDataAddr[i].id,poolId);
} }
@ -172,6 +177,7 @@ int msgSpaceDelete(msgSpaceId spaceId){
} }
space = msgSpaceOpen(spaceId); space = msgSpaceOpen(spaceId);
/* TODO: supprimer chaque pool */
printf("openned successfully !\n"); printf("openned successfully !\n");
printf("Unlinking DataTab... "); printf("Unlinking DataTab... ");