--- rpl/src/gestion_objets.c 2011/11/26 10:01:26 1.75 +++ rpl/src/gestion_objets.c 2011/11/26 13:05:03 1.76 @@ -544,6 +544,7 @@ allocation(struct_processus *s_etat_proc return(NULL); } + (*((struct_mutex *) (*s_objet).objet)).tid = pthread_self(); break; } @@ -1103,6 +1104,28 @@ liberation(struct_processus *s_etat_proc return; } + if (pthread_mutex_trylock(&((*((struct_mutex *) + (*s_objet).objet)).mutex)) == 0) + { + // On a pu verrouiller le mutex. Il faut donc spécifier le tid. + (*((struct_mutex *) (*s_objet).objet)).tid = pthread_self(); + } + + if (pthread_equal(pthread_self(), + (*((struct_mutex *) (*s_objet).objet)).tid) != 0) + { + pthread_mutex_unlock(&((*((struct_mutex *) + (*s_objet).objet)).mutex)); + } + else + { + (*s_etat_processus).erreur_systeme = + d_es_mutex_acquis_autre_thread; + return; + } + + pthread_mutex_destroy(&((*((struct_mutex *) + (*s_objet).objet)).mutex)); free((struct_mutex *) (*s_objet).objet); break; } @@ -2218,7 +2241,7 @@ copie_objet(struct_processus *s_etat_pro { // La duplication d'un mutex renvoie le même objet. incrementation_atomique(s_objet); - break; + return(s_objet); } case NOM :