Diff for /rpl/src/gestion_objets.c between versions 1.8 and 1.17

version 1.8, 2010/03/09 10:18:44 version 1.17, 2010/05/16 19:36:20
Line 1 Line 1
 /*  /*
 ================================================================================  ================================================================================
   RPL/2 (R) version 4.0.13    RPL/2 (R) version 4.0.15
   Copyright (C) 1989-2010 Dr. BERTRAND Joël    Copyright (C) 1989-2010 Dr. BERTRAND Joël
   
   This file is part of RPL/2.    This file is part of RPL/2.
Line 877  liberation(struct_processus *s_etat_proc Line 877  liberation(struct_processus *s_etat_proc
         {          {
             if (decrementation_atomique(s_objet) > 0)              if (decrementation_atomique(s_objet) > 0)
             {              {
                   liberation(s_etat_processus, (*((struct_fichier *)
                           (*s_objet).objet)).format);
                 return;                  return;
             }              }
   
Line 1208  liberation(struct_processus *s_etat_proc Line 1210  liberation(struct_processus *s_etat_proc
         {          {
             if (decrementation_atomique(s_objet) > 0)              if (decrementation_atomique(s_objet) > 0)
             {              {
                   liberation(s_etat_processus, (*((struct_socket *)
                           (*s_objet).objet)).format);
                 return;                  return;
             }              }
   
Line 1749  copie_objet(struct_processus *s_etat_pro Line 1753  copie_objet(struct_processus *s_etat_pro
             if (type == 'P')              if (type == 'P')
             {              {
                 incrementation_atomique(s_objet);                  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);                  return(s_objet);
             }              }
   
Line 2265  copie_objet(struct_processus *s_etat_pro Line 2277  copie_objet(struct_processus *s_etat_pro
             if (type == 'P')              if (type == 'P')
             {              {
                 incrementation_atomique(s_objet);                  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);                  return(s_objet);
             }              }
   
Line 2721  copie_etat_processus(struct_processus *s Line 2741  copie_etat_processus(struct_processus *s
      * n'ont aucune raison de changer.       * n'ont aucune raison de changer.
      */       */
   
   #   ifndef SEMAPHORES_NOMMES
     sem_init(&((*s_nouvel_etat_processus).semaphore_fork), 0, 0);      sem_init(&((*s_nouvel_etat_processus).semaphore_fork), 0, 0);
   #   else
       if (((*s_nouvel_etat_processus).semaphore_fork = sem_init2(0, sem_fork))
               == SEM_FAILED)
       {
           (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
           return(NULL);
       }
   #   endif
   
     (*s_nouvel_etat_processus).var_volatile_processus_pere = 0;      (*s_nouvel_etat_processus).var_volatile_processus_pere = 0;
     (*s_nouvel_etat_processus).fichiers_graphiques = NULL;      (*s_nouvel_etat_processus).fichiers_graphiques = NULL;
Line 2753  copie_etat_processus(struct_processus *s Line 2782  copie_etat_processus(struct_processus *s
     (*s_nouvel_etat_processus).nombre_interruptions_en_queue = 0;      (*s_nouvel_etat_processus).nombre_interruptions_en_queue = 0;
     (*s_nouvel_etat_processus).nombre_interruptions_non_affectees = 0;      (*s_nouvel_etat_processus).nombre_interruptions_non_affectees = 0;
   
       (*s_nouvel_etat_processus).at_exit = NULL;
   
     for(i = 0; i < d_NOMBRE_INTERRUPTIONS; i++)      for(i = 0; i < d_NOMBRE_INTERRUPTIONS; i++)
     {      {
         (*s_nouvel_etat_processus).corps_interruptions[i] = NULL;          (*s_nouvel_etat_processus).corps_interruptions[i] = NULL;
Line 3032  copie_etat_processus(struct_processus *s Line 3063  copie_etat_processus(struct_processus *s
                 (*s_etat_processus).s_liste_variables[i].niveau;                  (*s_etat_processus).s_liste_variables[i].niveau;
         (*s_nouvel_etat_processus).s_liste_variables[i].variable_statique =          (*s_nouvel_etat_processus).s_liste_variables[i].variable_statique =
                 (*s_etat_processus).s_liste_variables[i].variable_statique;                  (*s_etat_processus).s_liste_variables[i].variable_statique;
           (*s_nouvel_etat_processus).s_liste_variables[i].variable_partagee =
                   (*s_etat_processus).s_liste_variables[i].variable_partagee;
         (*s_nouvel_etat_processus).s_liste_variables[i].variable_verrouillee =          (*s_nouvel_etat_processus).s_liste_variables[i].variable_verrouillee =
                 (*s_etat_processus).s_liste_variables[i].variable_verrouillee;                  (*s_etat_processus).s_liste_variables[i].variable_verrouillee;
   
Line 3522  copie_etat_processus(struct_processus *s Line 3555  copie_etat_processus(struct_processus *s
   
 #undef fprintf  #undef fprintf
   
   #ifdef __BACKTRACE
 #define return(a) { if (a == NULL) \  #define return(a) { if (a == NULL) \
         { BACKTRACE(20); fprintf(stderr, ">>> MEDITATION %d\n", __LINE__); } \          { BACKTRACE(20); fprintf(stderr, ">>> MEDITATION %d\n", __LINE__); } \
         return(a); } while(0)          return(a); } while(0)
   #define PROFONDEUR_PILE 64
   #endif
   
 typedef struct memoire  typedef struct memoire
 {  {
Line 3534  typedef struct memoire Line 3570  typedef struct memoire
     unsigned long       ligne;      unsigned long       ligne;
     size_t              taille;      size_t              taille;
     unsigned long long  ordre;      unsigned long long  ordre;
   #   ifdef __BACKTRACE
       void                *pile[PROFONDEUR_PILE];
       int                 profondeur;
   #   endif
     struct memoire      *suivant;      struct memoire      *suivant;
 } struct_memoire;  } struct_memoire;
   
Line 3542  static unsigned long long ordre = 0; Line 3582  static unsigned long long ordre = 0;
 static pthread_mutex_t      mutex_allocation = PTHREAD_MUTEX_INITIALIZER;  static pthread_mutex_t      mutex_allocation = PTHREAD_MUTEX_INITIALIZER;
   
 #define check(a, b) ((strcmp(#a, fonction) == 0) && (ligne == b))  #define check(a, b) ((strcmp(#a, fonction) == 0) && (ligne == b))
   #define CORE_DUMP
   
 void *  void *
 debug_memoire_ajout(size_t taille, const unsigned char *fonction,  debug_memoire_ajout(size_t taille, const unsigned char *fonction,
Line 3570  debug_memoire_ajout(size_t taille, const Line 3611  debug_memoire_ajout(size_t taille, const
     (*debug).taille = taille;      (*debug).taille = taille;
     (*debug).ordre = ordre;      (*debug).ordre = ordre;
   
   #   ifdef __BACKTRACE
       (*debug).profondeur = backtrace((*debug).pile, PROFONDEUR_PILE);
   #   endif
   
     pthread_mutex_unlock(&mutex_allocation);      pthread_mutex_unlock(&mutex_allocation);
   
     if (((*debug).fonction = malloc((strlen(fonction) + 1) *      if (((*debug).fonction = malloc((strlen(fonction) + 1) *
Line 3713  debug_memoire_retrait(void *pointeur) Line 3758  debug_memoire_retrait(void *pointeur)
 }  }
   
 void  void
 debug_memoire_verification(struct_processus *s_etat_processus)  debug_memoire_verification()
 {  {
   #   ifdef __BACKTRACE
       char            **appels;
   
       int             j;
   #   endif
   
     integer8        i;      integer8        i;
   
     struct_memoire  *element_courant;      struct_memoire  *element_courant;
     struct_memoire  *element_suivant;      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());              getpid(), (unsigned long long) pthread_self());
   
     pthread_mutex_lock(&mutex_allocation);      pthread_mutex_lock(&mutex_allocation);
Line 3742  debug_memoire_verification(struct_proces Line 3793  debug_memoire_verification(struct_proces
                 (unsigned long long) pthread_self(),                  (unsigned long long) pthread_self(),
                 (*element_courant).argument);                  (*element_courant).argument);
   
         switch(i)  #       ifdef __BACKTRACE
           appels = backtrace_symbols((*element_courant).pile,
                   (*element_courant).profondeur);
   
           fprintf(stderr, "[%d-%llu] BACKTRACE\n",
                   getpid(), (unsigned long long) pthread_self());
   
           if (appels != NULL)
         {          {
             // Affichage des méditations              for(j = 0; j < (*element_courant).profondeur; j++)
             case 1:  
             {              {
                 break;                  fprintf(stderr, "[%d-%llu] %s\n", getpid(),
                           (unsigned long long) pthread_self(), appels[j]);
             }              }
   
               free(appels);
         }          }
   #       endif
   
           fprintf(stderr, "\n");
   
         i++;          i++;
   
         element_suivant = (*element_courant).suivant;          element_suivant = (*element_courant).suivant;
   
   #       ifndef CORE_DUMP
         free((*element_courant).fonction);          free((*element_courant).fonction);
         free((*element_courant).argument);          free((*element_courant).argument);
         free(element_courant);          free(element_courant);
   #       endif
   
         element_courant = element_suivant;          element_courant = element_suivant;
     }      }
   
Line 3767  debug_memoire_verification(struct_proces Line 3834  debug_memoire_verification(struct_proces
   
     return;      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  #endif
   

Removed from v.1.8  
changed lines
  Added in v.1.17


CVSweb interface <joel.bertrand@systella.fr>