--- rpl/src/gestion_objets.c 2010/05/13 19:09:18 1.16 +++ rpl/src/gestion_objets.c 2010/05/16 19:36:20 1.17 @@ -877,6 +877,8 @@ liberation(struct_processus *s_etat_proc { if (decrementation_atomique(s_objet) > 0) { + liberation(s_etat_processus, (*((struct_fichier *) + (*s_objet).objet)).format); return; } @@ -1208,6 +1210,8 @@ liberation(struct_processus *s_etat_proc { if (decrementation_atomique(s_objet) > 0) { + liberation(s_etat_processus, (*((struct_socket *) + (*s_objet).objet)).format); return; } @@ -1749,6 +1753,14 @@ copie_objet(struct_processus *s_etat_pro if (type == 'P') { incrementation_atomique(s_objet); + + if (((*((struct_fichier *) ((*s_objet).objet))).format = + copie_objet(s_etat_processus, (*((struct_fichier *) + ((*s_objet).objet))).format, 'P')) == NULL) + { + return(NULL); + } + return(s_objet); } @@ -2265,6 +2277,14 @@ copie_objet(struct_processus *s_etat_pro if (type == 'P') { incrementation_atomique(s_objet); + + if (((*((struct_socket *) ((*s_nouvel_objet).objet))).format = + copie_objet(s_etat_processus, (*((struct_socket *) + ((*s_objet).objet))).format, 'P')) == NULL) + { + return(NULL); + } + return(s_objet); } @@ -3555,8 +3575,6 @@ typedef struct memoire int profondeur; # endif struct memoire *suivant; - pthread_t thread; - pid_t pid; } struct_memoire; static struct_memoire *debug = NULL; @@ -3564,6 +3582,7 @@ static unsigned long long ordre = 0; static pthread_mutex_t mutex_allocation = PTHREAD_MUTEX_INITIALIZER; #define check(a, b) ((strcmp(#a, fonction) == 0) && (ligne == b)) +#define CORE_DUMP void * debug_memoire_ajout(size_t taille, const unsigned char *fonction, @@ -3591,8 +3610,6 @@ debug_memoire_ajout(size_t taille, const (*debug).ligne = ligne; (*debug).taille = taille; (*debug).ordre = ordre; - (*debug).thread = pthread_self(); - (*debug).pid = getpid(); # ifdef __BACKTRACE (*debug).profondeur = backtrace((*debug).pile, PROFONDEUR_PILE); @@ -3741,20 +3758,20 @@ debug_memoire_retrait(void *pointeur) } void -debug_memoire_verification(struct_processus *s_etat_processus) +debug_memoire_verification() { # ifdef __BACKTRACE char **appels; -# endif int j; +# endif integer8 i; struct_memoire *element_courant; struct_memoire *element_suivant; - fprintf(stderr, "[%d-%llu] MEMORY LEAK\n", + fprintf(stderr, "[%d-%llu] LIST OF MEMORY LEAKS\n", getpid(), (unsigned long long) pthread_self()); pthread_mutex_lock(&mutex_allocation); @@ -3764,49 +3781,49 @@ debug_memoire_verification(struct_proces while(element_courant != NULL) { - if (((*element_courant).pid == getpid()) && - (pthread_equal((*element_courant).thread, pthread_self()) != 0)) - { - fprintf(stderr, "[%d-%llu] MEDITATION %lld (%llu)\n", getpid(), - (unsigned long long) pthread_self(), i, - (*element_courant).ordre); - fprintf(stderr, "[%d-%llu] P: %p, F: %s(), L: %lu, S: %d\n", - getpid(), (unsigned long long) pthread_self(), - (*element_courant).pointeur, - (*element_courant).fonction, (*element_courant).ligne, - (int) (*element_courant).taille); - fprintf(stderr, "[%d-%llu] A: %s\n", getpid(), - (unsigned long long) pthread_self(), - (*element_courant).argument); + fprintf(stderr, "[%d-%llu] MEDITATION %lld (%llu)\n", getpid(), + (unsigned long long) pthread_self(), i, + (*element_courant).ordre); + fprintf(stderr, "[%d-%llu] P: %p, F: %s(), L: %lu, S: %d\n", + getpid(), (unsigned long long) pthread_self(), + (*element_courant).pointeur, + (*element_courant).fonction, (*element_courant).ligne, + (int) (*element_courant).taille); + fprintf(stderr, "[%d-%llu] A: %s\n", getpid(), + (unsigned long long) pthread_self(), + (*element_courant).argument); -# ifdef __BACKTRACE - appels = backtrace_symbols((*element_courant).pile, - (*element_courant).profondeur); +# ifdef __BACKTRACE + appels = backtrace_symbols((*element_courant).pile, + (*element_courant).profondeur); - fprintf(stderr, "[%d-%llu] BACKTRACE\n", - getpid(), (unsigned long long) pthread_self()); + fprintf(stderr, "[%d-%llu] BACKTRACE\n", + getpid(), (unsigned long long) pthread_self()); - if (appels != NULL) + if (appels != NULL) + { + for(j = 0; j < (*element_courant).profondeur; j++) { - for(j = 0; j < (*element_courant).profondeur; j++) - { - fprintf(stderr, "[%d-%llu] %s\n", getpid(), - (unsigned long long) pthread_self(), appels[j]); - } - - free(appels); + fprintf(stderr, "[%d-%llu] %s\n", getpid(), + (unsigned long long) pthread_self(), appels[j]); } -# endif - - fprintf(stderr, "\n"); - i++; + free(appels); } +# endif + + fprintf(stderr, "\n"); + + i++; element_suivant = (*element_courant).suivant; + +# ifndef CORE_DUMP free((*element_courant).fonction); free((*element_courant).argument); free(element_courant); +# endif + element_courant = element_suivant; } @@ -3817,6 +3834,18 @@ debug_memoire_verification(struct_proces return; } + +void +analyse_post_mortem() +{ +# ifdef CORE_DUMP + BUG(debug != NULL, uprintf("[%d-%llu] CREATE CORE DUMP FILE FOR " + "POST MORTEM ANALYZE\n", getpid(), + (unsigned long long) pthread_self())); +# endif + + return; +} #endif