From 309678b6f484a123f6c3bec04c5d462fb5e50e32 Mon Sep 17 00:00:00 2001 From: glenux Date: Sun, 7 Mar 2004 12:53:25 +0000 Subject: [PATCH] *** empty log message *** --- src/queueProtLock.c | 5 ++--- src/queueProtUnlock.c | 3 ++- src/queueReadLock.c | 3 ++- src/queueReadTryLock.c | 7 ++++--- src/queueReadUnlock.c | 11 ++++++----- src/spaceCreate.c | 4 ++-- src/spaceDelete.c | 2 +- src/spaceListElemCreate.c | 4 ++-- src/spaceListFindId.c | 4 ++-- src/spaceListInit.c | 5 +++-- 10 files changed, 26 insertions(+), 22 deletions(-) diff --git a/src/queueProtLock.c b/src/queueProtLock.c index 476f5ab..7ff7a18 100644 --- a/src/queueProtLock.c +++ b/src/queueProtLock.c @@ -3,6 +3,7 @@ #define DEBUG 0 int msgQueueProtLock(msgSpaceId externId,int queueIdx){ + int semval; sem_t * queueSemFd; msgQueueSemId queueSemId; @@ -18,13 +19,11 @@ int msgQueueProtLock(msgSpaceId externId,int queueIdx){ NZG_ERROR("sem_wait",queueSemId); goto ERROR; } - int semval=0; + semval=0; sem_getvalue(queueSemFd,&semval); if (DEBUG) { printf("(AfterValue:%d)\n",semval); } sem_close(queueSemFd); - - sem_close(queueSemFd); return 0; diff --git a/src/queueProtUnlock.c b/src/queueProtUnlock.c index 1e6d8d9..89673cb 100644 --- a/src/queueProtUnlock.c +++ b/src/queueProtUnlock.c @@ -4,6 +4,7 @@ #define DEBUG 0 int msgQueueProtUnlock(msgSpaceId externId,int queueIdx){ + int semval; sem_t * queueSemFd; msgQueueSemId queueSemId; @@ -20,7 +21,7 @@ int msgQueueProtUnlock(msgSpaceId externId,int queueIdx){ NZG_ERROR("sem_post",queueSemId); goto ERROR; } - int semval=0; + semval=0; sem_getvalue(queueSemFd,&semval); if (DEBUG) { printf("(AfterValue:%d)\n",semval); } diff --git a/src/queueReadLock.c b/src/queueReadLock.c index b694749..16e1653 100644 --- a/src/queueReadLock.c +++ b/src/queueReadLock.c @@ -4,6 +4,7 @@ #define DEBUG 0 int msgQueueReadLock(msgSpaceId externId,int queueIdx){ + int semval; sem_t * queueSemFd; msgQueueSemId queueSemId; @@ -19,7 +20,7 @@ int msgQueueReadLock(msgSpaceId externId,int queueIdx){ NZG_ERROR("sem_wait",queueSemId); goto ERROR; } - int semval=0; + semval=0; sem_getvalue(queueSemFd,&semval); if (DEBUG) { printf("(AfterValue:%d)\n",semval); } diff --git a/src/queueReadTryLock.c b/src/queueReadTryLock.c index 3c33646..f2dc629 100644 --- a/src/queueReadTryLock.c +++ b/src/queueReadTryLock.c @@ -4,6 +4,7 @@ #define DEBUG 0 int msgQueueReadTryLock(msgSpaceId externId,int queueIdx){ + int semval; sem_t * queueSemFd; msgQueueSemId queueSemId; @@ -19,9 +20,9 @@ int msgQueueReadTryLock(msgSpaceId externId,int queueIdx){ goto ERROR; } if (DEBUG) { printf("Locking %s\n",queueSemId); } - int semval=0; - sem_getvalue(queueSemFd,&semval); - if (DEBUG) { printf("(AfterValue:%d)\n",semval); } + semval=0; + sem_getvalue(queueSemFd,&semval); + if (DEBUG) { printf("(AfterValue:%d)\n",semval); } sem_close(queueSemFd); diff --git a/src/queueReadUnlock.c b/src/queueReadUnlock.c index d6afbb6..5e4fb32 100644 --- a/src/queueReadUnlock.c +++ b/src/queueReadUnlock.c @@ -4,12 +4,13 @@ #define DEBUG 0 int msgQueueReadUnlock(msgSpaceId externId,int queueIdx){ - sem_t * queueSemFd; + int semval; + sem_t * queueSemFd; msgQueueSemId queueSemId; msgQueueReadSemIdIntern(queueSemId,externId,queueIdx); if (DEBUG) { printf("Unlocking %s\n",queueSemId); } - queueSemFd=sem_open(queueSemId,O_CREAT,SEM_DEFAULT_MODE,1); + queueSemFd=sem_open(queueSemId,O_CREAT,SEM_DEFAULT_MODE,1); if(queueSemFd==SEM_FAILED){ NZG_ERROR("sem_open",queueSemId); goto ERROR; @@ -19,9 +20,9 @@ int msgQueueReadUnlock(msgSpaceId externId,int queueIdx){ NZG_ERROR("sem_post",queueSemId); goto ERROR; } - int semval=0; - sem_getvalue(queueSemFd,&semval); - if (DEBUG) { printf("(AfterValue:%d)\n",semval); } + semval=0; + sem_getvalue(queueSemFd,&semval); + if (DEBUG) { printf("(AfterValue:%d)\n",semval); } sem_close(queueSemFd); diff --git a/src/spaceCreate.c b/src/spaceCreate.c index 2c2349c..1b08b88 100644 --- a/src/spaceCreate.c +++ b/src/spaceCreate.c @@ -22,8 +22,10 @@ msgSpace * msgSpaceCreate( /* msgSpaceList mSList; */ int mSFd; // shm file descriptor int i; + int err; static int mSIdNum=-1; msgSpace * space; + msgSpaceListElemId listElemId; msgPoolDataTabId poolDataTabId; msgPoolData * poolDataTabAddr; @@ -50,7 +52,6 @@ msgSpace * msgSpaceCreate( NZG_ERROR("msgSpaceListLock",""); goto ERROR; } - int err; if ((err=msgSpaceListFindId(externId)) < 1){ if (err==0){ // soit le msgSpace existe deja @@ -173,7 +174,6 @@ msgSpace * msgSpaceCreate( } msgPoolDataTabClose(space,poolDataTabAddr); /* on ajoute spaceId a la liste des msgSpace connus */ - msgSpaceListElemId listElemId; printf("spaceListInit...\n"); printf("ok\n"); diff --git a/src/spaceDelete.c b/src/spaceDelete.c index 16acfce..5a40cae 100644 --- a/src/spaceDelete.c +++ b/src/spaceDelete.c @@ -8,11 +8,11 @@ int msgPoolDataTabSemIdIntern( msgPoolSemId destSemId,const msgSpaceId externId); int msgSpaceDelete(msgSpaceId externId){ - fprintf(stderr,"Deleting msgSpace with id : %s\n",externId); //int shmId; msgSpaceId nzgId; msgSpace * space; int i; + fprintf(stderr,"Deleting msgSpace with id : %s\n",externId); if (msgSpaceIdIntern(nzgId,externId) == -1){ NZG_ERROR("msgSpaceIdIntern",externId); goto ERROR; diff --git a/src/spaceListElemCreate.c b/src/spaceListElemCreate.c index 8ba9e00..fa726ac 100644 --- a/src/spaceListElemCreate.c +++ b/src/spaceListElemCreate.c @@ -7,8 +7,9 @@ int msgSpaceListElemCreate( msgSpace * space) { - msgSpaceListElemIdIntern(listElemId,space->externId); int listElemFd; + msgSpaceListElem * listElem; + msgSpaceListElemIdIntern(listElemId,space->externId); listElemFd=shm_open(listElemId, O_RDWR|O_CREAT|O_EXCL|O_TRUNC, @@ -25,7 +26,6 @@ int msgSpaceListElemCreate( } close(listElemFd); - msgSpaceListElem * listElem; listElem=msgSpaceListElemOpen(listElemId); if (listElem ==NULL){ NZG_ERROR("msgSpaceListElemOpen",listElemId); diff --git a/src/spaceListFindId.c b/src/spaceListFindId.c index 1d9435c..312530c 100644 --- a/src/spaceListFindId.c +++ b/src/spaceListFindId.c @@ -5,11 +5,11 @@ int msgSpaceListFindId(msgSpaceId externId){ msgSpaceList * list; msgSpaceId spaceId; - - msgSpaceIdIntern(spaceId,externId); msgSpaceListElemId listHeadElemId; msgSpaceListElemId listTailElemId; msgSpaceListId listId; + + msgSpaceIdIntern(spaceId,externId); list=msgSpaceListOpen(); if (list==NULL){ NZG_ERROR("msgSpaceListOpen",""); diff --git a/src/spaceListInit.c b/src/spaceListInit.c index b1e052b..eadf0f9 100644 --- a/src/spaceListInit.c +++ b/src/spaceListInit.c @@ -4,9 +4,11 @@ int msgSpaceListInit(){ int spaceListFd; sem_t * spaceListSemFd; + msgSpaceList *list; msgSpaceListSemId spaceListSemId; msgSpaceListId spaceListId; + strcpy(spaceListSemId,DEFAULT_MSGSPACELISTSEMID); strcpy(spaceListId,DEFAULT_MSGSPACELISTID); @@ -42,7 +44,6 @@ int msgSpaceListInit(){ } close(spaceListFd); - msgSpaceList *list; list=msgSpaceListOpen(); if (list == NULL){ NZG_ERROR("msgSpaceListOpen",""); @@ -65,7 +66,7 @@ int msgSpaceListInit(){ ERROR: return -1; EXISTING: - if (msgSpaceListUnlock() < 0){ + if (msgSpaceListUnlock() < 0){ NZG_ERROR("msgSpaceListUnlock",""); goto ERROR; }