From 0857256f59d3a309c002ae7741306886d69f77c7 Mon Sep 17 00:00:00 2001 From: glenux Date: Mon, 23 Feb 2004 10:30:02 +0000 Subject: [PATCH] =?UTF-8?q?*=20ajout=C3=A9=20un=20semaphore=20de=20protect?= =?UTF-8?q?ion=20du=20DataTab=20(et=20des=20infos=20qui=20en=20d=C3=A9coul?= =?UTF-8?q?ent)=20*=20verrouill=C3=A9=20le=20semaphore=20dans=20create?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/nzg_allocate.c | 4 ++-- src/nzg_ids.c | 15 ++++++++++++++- src/nzg_poolCreate.c | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/nzg_allocate.c b/src/nzg_allocate.c index 2a2fc90..56e611b 100644 --- a/src/nzg_allocate.c +++ b/src/nzg_allocate.c @@ -162,7 +162,7 @@ void * msgAllocate(msgSpace *space, /* on acquiert le droit de modifier les infos sur la ressource */ poolDataTabSemFd=sem_open(space->poolDataTabSemId,O_CREAT,SEM_DEFAULT_MODE,1); - + printf("VOILAAA : %s\n",space->poolDataTabSemId); //sem_wait(poolDataTabSemFd); /* on modifie maintenant les données */ @@ -173,7 +173,7 @@ void * msgAllocate(msgSpace *space, // aucun buffer libre ? return NULL; } - printf("Buffer %d libre a attacher !\n",bufferFreeIndex); + printf("Buffer selected : %d,%d\n",selectedPoolIndex,bufferFreeIndex); /*TODO: mapper le buffer libre dans l'esp addr du proc */ //TODO: /* - on s'enregistre aupres de ce buffer */ diff --git a/src/nzg_ids.c b/src/nzg_ids.c index 960f28a..3a17866 100644 --- a/src/nzg_ids.c +++ b/src/nzg_ids.c @@ -16,7 +16,20 @@ int msgSpaceIdIntern(msgSpaceId dest,const msgSpaceId src ){ #endif return 0; } - +int msgPoolDataTabSemIdIntern( + msgPoolSemId destSemId, + const msgSpaceId externId){ + if (strlen(externId)>MSGSPACE_ID_LEN*4){ + return -1; + } + /* sprintf(resNzgId,"/tmp/.nzg-%s",(char *)spaceId); */ +#ifdef _NZG_REALFILEID + sprintf(destSemId,"/tmp/nzgPoolDTSem-%s",(char *)externId); +#else + sprintf(destSemId,"/nzgPoolDTSem-%s",(char *)externId); +#endif + return 0; +} int msgPoolSemIdIntern( msgPoolSemId destSemId, const msgSpaceId srcPoolId, diff --git a/src/nzg_poolCreate.c b/src/nzg_poolCreate.c index b3ac79a..41deaa4 100644 --- a/src/nzg_poolCreate.c +++ b/src/nzg_poolCreate.c @@ -38,7 +38,7 @@ int msgPoolCreate( } // on met un semaphore sur le pool - ressourceSemFd = sem_open(poolRessourceSemId, O_CREAT|O_EXCL, 0666, buffNb); + ressourceSemFd = sem_open(poolRessourceSemId, O_CREAT|O_EXCL,SEM_DEFAULT_MODE, buffNb); if (ressourceSemFd == SEM_FAILED){ NZG_ERROR("sem_open : creation de la ressource",poolRessourceSemId); return -1;