From f8bcc4c6f55aa0711e2517ff152ad1b7e3108ee8 Mon Sep 17 00:00:00 2001 From: rivka_zan Date: Mon, 23 Feb 2004 20:23:23 +0000 Subject: [PATCH] *modification des fiction locke t unlock --- src/spaceListLocking.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/spaceListLocking.c b/src/spaceListLocking.c index cb9b9b6..fa7cba3 100644 --- a/src/spaceListLocking.c +++ b/src/spaceListLocking.c @@ -13,22 +13,25 @@ int msgSpaceListLock(){ spacesListSemFd=sem_open(spacesListSemId,O_CREAT|O_EXCL,0666,1024); if(spacesListSemFd==SEM_FAILED){ NZG_ERROR("sem_open",spacesListSemId); - return -1; + goto ERROR; } /*Pose d'un semaphore et le verrouille*/ if(sem_wait(spacesListSemFd)==-1){ NZG_ERROR("sem_wait",spacesListSemId); - return -1; + goto ERROR; } /* Ferme le semaphore*/ - if(sem_close(spacesListSemFd)==-1){ + /* if(sem_close(spacesListSemFd)==-1){ NZG_ERROR("sem_close",spacesListSemId); return -1; - } + }*/ + sem_close(spacesListSemFd); return 0; +ERROR: + return -1; } @@ -36,29 +39,30 @@ int msgSpaceListLock(){ int msgSpaceListUnlock(){ sem_t * spacesListSemFd; msgSpaceListSemId spacesListSemId; - + /*Ouverture dun semaphore*/ spacesListSemFd=sem_open(spacesListSemId,O_CREAT|O_EXCL,0666,1024); if(spacesListSemFd==SEM_FAILED){ NZG_ERROR("sem_open",spacesListSemId); - return -1; + goto ERROR; } /*Relachement du semaphore*/ if(sem_post(spacesListSemFd)==-1){ NZG_ERROR("sem_relache",spacesListSemId); - return -1; + goto ERROR; } - /* Ferme le semaphore*/ - if(sem_close(spacesListSemFd)==-1){ - NZG_ERROR("sem_close",spacesListSemId); - return -1; - } - + /* Ferme le semaphore + if(sem_close(spacesListSemFd)==-1){ + NZG_ERROR("sem_close",spacesListSemId); + return -1; + }*/ return 0; +ERROR: + return -1; };