*corection de la fonction msgSpaceListUnlock

This commit is contained in:
rivka_zan 2004-02-23 16:02:25 +00:00
parent 025e63852c
commit 1a39b8e7f2

View file

@ -16,13 +16,19 @@ int msgSpaceListLock(){
return -1; return -1;
} }
/*Pose d'un semafore et bloque*/ /*Pose d'un semaphore et le verrouille*/
if(sem_wait(spacesListSemFd)==-1){ if(sem_wait(spacesListSemFd)==-1){
NZG_ERROR("sem_wait",spacesListSemId); NZG_ERROR("sem_wait",spacesListSemId);
return -1; return -1;
} }
return 0;
/* Ferme le semaphore*/
if(sem_close(spacesListSemFd)==-1){
NZG_ERROR("sem_close",spacesListSemId);
return -1;
}
return 0;
} }
@ -31,16 +37,28 @@ int msgSpaceListUnlock(){
sem_t * spacesListSemFd; sem_t * spacesListSemFd;
msgSpaceListSemId spacesListSemId; 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;
}
/*Relachement du semaphore*/
if(sem_post(spacesListSemFd)==-1){
NZG_ERROR("sem_relache",spacesListSemId);
return -1;
}
/* Ferme le semaphore*/ /* Ferme le semaphore*/
if(sem_close(spacesListSemFd)==-1){ if(sem_close(spacesListSemFd)==-1){
NZG_ERROR("sem_close",spacesListSemId); NZG_ERROR("sem_close",spacesListSemId);
return -1; return -1;
} }
/*semaphore non bloquant*/
if (sem_trywait(spacesListSemFd)==-1){
NZG_ERROR("sem_trywait",spacesListSemId);
return -1;
}
return 0; return 0;
}; };