--- rpl/src/semaphores.c 2011/09/20 14:36:30 1.34 +++ rpl/src/semaphores.c 2011/09/20 15:45:53 1.35 @@ -29,7 +29,7 @@ // est dans ce cas. static unsigned char * -nom_segment_semaphore(pid_t pid) +nom_segment_semaphore(pid_t pid, int ordre) { unsigned char *fichier; @@ -38,13 +38,13 @@ nom_segment_semaphore(pid_t pid) return(NULL); } - sprintf(fichier, "/RPL-SS-%d", (int) pid); + sprintf(fichier, "/RPL-%d-%d", (int) pid, ordre); return(fichier); } static unsigned char * -nom_segment_semaphore_thread(pid_t pid, pthread_t tid) +nom_segment_semaphore_thread(pid_t pid, pthread_t tid, int ordre) { unsigned char *fichier; @@ -53,8 +53,8 @@ nom_segment_semaphore_thread(pid_t pid, return(NULL); } - sprintf(fichier, "/RPL-SS-%d-%llx", (int) pid, - (unsigned long long) tid); + sprintf(fichier, "/RPL-%d-%llX-%d", (int) pid, + (unsigned long long) tid, ordre); return(fichier); } @@ -72,14 +72,13 @@ nom_segment_semaphore_thread(pid_t pid, */ sem_t * -sem_init2(unsigned int valeur, pid_t pid) +sem_init2(unsigned int valeur, pid_t pid, int ordre) { sem_t *semaphore; unsigned char *chemin; - unsigned int i; - if ((chemin = nom_segment_semaphore(pid)) == NULL) + if ((chemin = nom_segment_semaphore(pid, ordre)) == NULL) { return(SEM_FAILED); } @@ -93,14 +92,13 @@ sem_init2(unsigned int valeur, pid_t pid sem_t * -sem_init3(unsigned int valeur, pid_t pid, pthread_t tid) +sem_init3(unsigned int valeur, pid_t pid, pthread_t tid, int ordre) { sem_t *semaphore; unsigned char *chemin; - unsigned int i; - if ((chemin = nom_segment_semaphore_thread(pid, tid)) == NULL) + if ((chemin = nom_segment_semaphore_thread(pid, tid, ordre)) == NULL) { return(SEM_FAILED); } @@ -114,13 +112,13 @@ sem_init3(unsigned int valeur, pid_t pid sem_t * -sem_open2(pid_t pid) +sem_open2(pid_t pid, int ordre) { unsigned char *chemin; sem_t *semaphore; - if ((chemin = nom_segment_semaphore(pid)) == NULL) + if ((chemin = nom_segment_semaphore(pid, ordre)) == NULL) { return(SEM_FAILED); } @@ -133,7 +131,7 @@ sem_open2(pid_t pid) int -sem_destroy2(sem_t *semaphore, pid_t pid) +sem_destroy2(sem_t *semaphore, pid_t pid, int ordre) { int erreur; @@ -141,7 +139,7 @@ sem_destroy2(sem_t *semaphore, pid_t pid sem_close(semaphore); - if ((chemin = nom_segment_semaphore(pid)) == NULL) + if ((chemin = nom_segment_semaphore(pid, ordre)) == NULL) { return(1); } @@ -154,7 +152,7 @@ sem_destroy2(sem_t *semaphore, pid_t pid int -sem_destroy3(sem_t *semaphore, pid_t pid, pthread_t tid) +sem_destroy3(sem_t *semaphore, pid_t pid, pthread_t tid, int ordre) { int erreur; @@ -162,7 +160,7 @@ sem_destroy3(sem_t *semaphore, pid_t pid sem_close(semaphore); - if ((chemin = nom_segment_semaphore_thread(pid, tid)) == NULL) + if ((chemin = nom_segment_semaphore_thread(pid, tid, ordre)) == NULL) { return(1); } @@ -299,9 +297,9 @@ sem_init_SysV(sem_t *semaphore, int shar return(-1); } - sprintf((*semaphore).path, "%s/RPL-SIGSEMAPHORE-%d-%llu", + sprintf((*semaphore).path, "%s/RPL-SIGSEMAPHORE-%d-%llX", racine_segment, pthread_self(), - (int) getpid()); + (int) getpid(), pthread_self()); if ((desc = open((*semaphore).path, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR)) == -1)