--- rpl/src/gestion_objets.c 2010/08/30 14:14:07 1.39 +++ rpl/src/gestion_objets.c 2011/04/11 12:10:05 1.46 @@ -1,7 +1,7 @@ /* ================================================================================ - RPL/2 (R) version 4.0.19 - Copyright (C) 1989-2010 Dr. BERTRAND Joël + RPL/2 (R) version 4.1.0.prerelease.0 + Copyright (C) 1989-2011 Dr. BERTRAND Joël This file is part of RPL/2. @@ -57,7 +57,7 @@ decrementation_atomique(struct_objet *s_ return((*s_objet).nombre_occurrences); } -inline void +void initialisation_objet(struct_objet *s_objet) { pthread_mutexattr_t attributs_mutex; @@ -758,6 +758,9 @@ liberation(struct_processus *s_etat_proc { logical1 drapeau; + sigset_t oldset; + sigset_t set; + struct_liste_chainee *l_element_courant; struct_liste_chainee *l_element_suivant; @@ -1127,9 +1130,15 @@ liberation(struct_processus *s_etat_proc case PRC : { + sigfillset(&set); + pthread_sigmask(SIG_BLOCK, &set, &oldset); + if (pthread_mutex_lock(&((*(*((struct_processus_fils *) - (*s_objet).objet)).thread).mutex)) != 0) + (*s_objet).objet)).thread).mutex_nombre_references)) != 0) { + pthread_sigmask(SIG_SETMASK, &oldset, NULL); + sigpending(&set); + (*s_etat_processus).erreur_systeme = d_es_processus; return; } @@ -1155,18 +1164,25 @@ liberation(struct_processus *s_etat_proc } if (pthread_mutex_unlock(&((*(*((struct_processus_fils *) - (*s_objet).objet)).thread).mutex)) != 0) + (*s_objet).objet)).thread).mutex_nombre_references)) != 0) { + pthread_sigmask(SIG_SETMASK, &oldset, NULL); + sigpending(&set); + (*s_etat_processus).erreur_systeme = d_es_processus; return; } + pthread_sigmask(SIG_SETMASK, &oldset, NULL); + sigpending(&set); + if (drapeau == d_vrai) { pthread_mutex_destroy(&((*(*((struct_processus_fils *) (*s_objet).objet)).thread).mutex)); + pthread_mutex_destroy(&((*(*((struct_processus_fils *) + (*s_objet).objet)).thread).mutex_nombre_references)); free((*((struct_processus_fils *) (*s_objet).objet)).thread); - } if (decrementation_atomique(s_objet) > 0) @@ -1497,6 +1513,9 @@ struct_objet * copie_objet(struct_processus *s_etat_processus, struct_objet *s_objet, unsigned char type) { + sigset_t oldset; + sigset_t set; + struct_liste_chainee *l_element_base; struct_liste_chainee *l_element_courant; struct_liste_chainee *l_element_courant_ecriture; @@ -2267,9 +2286,15 @@ copie_objet(struct_processus *s_etat_pro case PRC : { + sigfillset(&set); + pthread_sigmask(SIG_BLOCK, &set, &oldset); + if (pthread_mutex_lock(&((*(*((struct_processus_fils *) - (*s_objet).objet)).thread).mutex)) != 0) + (*s_objet).objet)).thread).mutex_nombre_references)) != 0) { + pthread_sigmask(SIG_SETMASK, &oldset, NULL); + sigpending(&set); + return(NULL); } @@ -2277,11 +2302,17 @@ copie_objet(struct_processus *s_etat_pro .nombre_references++; if (pthread_mutex_unlock(&((*(*((struct_processus_fils *) - (*s_objet).objet)).thread).mutex)) != 0) + (*s_objet).objet)).thread).mutex_nombre_references)) != 0) { + pthread_sigmask(SIG_SETMASK, &oldset, NULL); + sigpending(&set); + return(NULL); } + pthread_sigmask(SIG_SETMASK, &oldset, NULL); + sigpending(&set); + if (type != 'O') { incrementation_atomique(s_objet); @@ -2295,7 +2326,6 @@ copie_objet(struct_processus *s_etat_pro (*((struct_processus_fils *) (*s_nouvel_objet).objet)) = (*((struct_processus_fils *) (*s_objet).objet)); - break; }