--- rpl/src/instructions_p4.c 2013/03/20 22:24:36 1.47 +++ rpl/src/instructions_p4.c 2013/03/23 16:14:39 1.48 @@ -471,6 +471,7 @@ void instruction_prusr(struct_processus *s_etat_processus) { integer8 i; + integer8 j; integer8 nb_variables; struct_objet s_objet; @@ -510,6 +511,12 @@ instruction_prusr(struct_processus *s_et } } + if (pthread_mutex_lock(&mutex_liste_variables_partagees) != 0) + { + (*s_etat_processus).erreur_systeme = d_es_processus; + return; + } + nb_variables = nombre_variables(s_etat_processus); if ((tableau = malloc(((size_t) nb_variables) * @@ -517,11 +524,18 @@ instruction_prusr(struct_processus *s_et { liberation_mutexes_arbre_variables_partagees(s_etat_processus, (*(*s_etat_processus).s_arbre_variables_partagees)); + pthread_mutex_unlock(&mutex_liste_variables_partagees); (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } - liste_variables(s_etat_processus, tableau); + nb_variables = liste_variables(s_etat_processus, tableau); + + if (pthread_mutex_unlock(&mutex_liste_variables_partagees) != 0) + { + (*s_etat_processus).erreur_systeme = d_es_processus; + return; + } s_objet.type = CHN; @@ -530,6 +544,14 @@ instruction_prusr(struct_processus *s_et if ((s_objet.objet = malloc((strlen(tableau[i].nom) + 64) * sizeof(unsigned char))) == NULL) { + for(j = i; j < nb_variables; j++) + { + if (tableau[j].mutex != NULL) + { + pthread_mutex_unlock(tableau[i].mutex); + } + } + free(tableau); (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; @@ -539,6 +561,11 @@ instruction_prusr(struct_processus *s_et sprintf((unsigned char *) s_objet.objet, "\\\\noindent %s [%lld]\n", tableau[i].nom, tableau[i].niveau); + if (tableau[i].mutex != NULL) + { + pthread_mutex_unlock(tableau[i].mutex); + } + formateur_tex(s_etat_processus, &s_objet, 'N'); free(s_objet.objet); }