--- rpl/src/gestion_variables_partagees.c 2012/12/18 10:20:24 1.40 +++ rpl/src/gestion_variables_partagees.c 2017/08/03 17:17:44 1.66 @@ -1,7 +1,7 @@ /* ================================================================================ - RPL/2 (R) version 4.1.11 - Copyright (C) 1989-2012 Dr. BERTRAND Joël + RPL/2 (R) version 4.1.28 + Copyright (C) 1989-2017 Dr. BERTRAND Joël This file is part of RPL/2. @@ -84,7 +84,8 @@ allocation_tableau_noeuds_partages(struc } else { - objet = malloc((*s_etat_processus).nombre_caracteres_variables + objet = malloc(((size_t) (*s_etat_processus) + .nombre_caracteres_variables) * sizeof(struct_arbre_variables_partagees *)); } @@ -448,6 +449,7 @@ recherche_variable_partagee(struct_proce { // Caractère hors de l'alphabet des variables + pthread_mutex_unlock(&((*l_variable_courante).mutex_feuille)); (*s_etat_processus).erreur_systeme = d_es_variable_introuvable; return(NULL); } @@ -455,6 +457,8 @@ recherche_variable_partagee(struct_proce if ((*l_variable_courante).noeuds[pointeur] == NULL) { // Le chemin de la variable candidate n'existe pas. + + pthread_mutex_unlock(&((*l_variable_courante).mutex_feuille)); (*s_etat_processus).erreur_systeme = d_es_variable_introuvable; return(NULL); } @@ -462,6 +466,7 @@ recherche_variable_partagee(struct_proce if (pthread_mutex_lock(&((*(*l_variable_courante).noeuds[pointeur]) .mutex_feuille)) != 0) { + pthread_mutex_unlock(&((*l_variable_courante).mutex_feuille)); (*s_etat_processus).erreur_systeme = d_es_processus; return(NULL); } @@ -478,7 +483,7 @@ recherche_variable_partagee(struct_proce if ((*l_variable_courante).feuille != NULL) { - // Il existe au moins une variable statique du nom requis. + // Il existe au moins une variable partagée du nom requis. l_element_courant = (*l_variable_courante).feuille; @@ -655,6 +660,8 @@ retrait_variable_partagee(struct_process liberation(s_etat_processus, (*(*l_element_a_supprimer).variable) .objet); free((*(*l_element_a_supprimer).variable).nom); + pthread_mutex_unlock(&((*(*l_element_a_supprimer).variable).mutex)); + pthread_mutex_destroy(&((*(*l_element_a_supprimer).variable).mutex)); free((*l_element_a_supprimer).variable); free(l_element_a_supprimer);