Diff for /rpl/src/interruptions.c between versions 1.17 and 1.37

version 1.17, 2010/05/22 21:45:50 version 1.37, 2010/08/26 19:07:41
Line 1 Line 1
 /*  /*
 ================================================================================  ================================================================================
   RPL/2 (R) version 4.0.15    RPL/2 (R) version 4.0.19
   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 20 Line 20
 */  */
   
   
 #include "rpl.conv.h"  #include "rpl-conv.h"
   
   
 /*  /*
Line 125  insertion_thread(struct_processus *s_eta Line 125  insertion_thread(struct_processus *s_eta
     }      }
   
     (*l_nouvel_objet).suivant = liste_threads;      (*l_nouvel_objet).suivant = liste_threads;
   
     liste_threads = l_nouvel_objet;      liste_threads = l_nouvel_objet;
   
 #   ifndef SEMAPHORES_NOMMES  #   ifndef SEMAPHORES_NOMMES
Line 184  insertion_thread_surveillance(struct_pro Line 183  insertion_thread_surveillance(struct_pro
         }          }
     }      }
   
       pthread_mutex_lock(&((*s_argument_thread).mutex));
       (*s_argument_thread).nombre_references++;
       pthread_mutex_unlock(&((*s_argument_thread).mutex));
   
     (*l_nouvel_objet).suivant = liste_threads_surveillance;      (*l_nouvel_objet).suivant = liste_threads_surveillance;
     (*l_nouvel_objet).donnee = (void *) s_argument_thread;      (*l_nouvel_objet).donnee = (void *) s_argument_thread;
   
Line 448  retrait_thread_surveillance(struct_proce Line 451  retrait_thread_surveillance(struct_proce
   
     pthread_sigmask(SIG_SETMASK, &oldset, NULL);      pthread_sigmask(SIG_SETMASK, &oldset, NULL);
     sigpending(&set);      sigpending(&set);
   
     return;      return;
 }  }
   
Line 669  liberation_threads(struct_processus *s_e Line 673  liberation_threads(struct_processus *s_e
                     .l_base_pile_processus;                      .l_base_pile_processus;
             while(element_courant != NULL)              while(element_courant != NULL)
             {              {
                 pthread_mutex_trylock(&((*(*((struct_liste_chainee *)                  s_argument_thread = (struct_descripteur_thread *)
                         element_courant)).donnee).mutex));                          (*((struct_liste_chainee *) element_courant)).donnee;
                 pthread_mutex_unlock(&((*(*((struct_liste_chainee *)  
                         element_courant)).donnee).mutex));                  if (pthread_mutex_lock(&((*s_argument_thread).mutex)) != 0)
                 liberation(s_etat_processus,                  {
                         (*((struct_liste_chainee *) element_courant)).donnee);                      (*s_etat_processus).erreur_systeme = d_es_processus;
                       sem_post(&semaphore_liste_threads);
                       return;
                   }
   
                   (*s_argument_thread).nombre_references--;
   
                   BUG((*s_argument_thread).nombre_references < 0,
                           printf("(*s_argument_thread).nombre_references = %d\n",
                           (int) (*s_argument_thread).nombre_references));
   
                   if ((*s_argument_thread).nombre_references == 0)
                   {
                       close((*s_argument_thread).pipe_objets[0]);
                       close((*s_argument_thread).pipe_acquittement[1]);
                       close((*s_argument_thread).pipe_injections[1]);
                       close((*s_argument_thread).pipe_nombre_injections[1]);
                       close((*s_argument_thread).pipe_nombre_objets_attente[0]);
                       close((*s_argument_thread).pipe_interruptions[0]);
                       close((*s_argument_thread)
                               .pipe_nombre_interruptions_attente[0]);
   
                       if (pthread_mutex_unlock(&((*s_argument_thread).mutex))
                               != 0)
                       {
                           (*s_etat_processus).erreur_systeme = d_es_processus;
                           sem_post(&semaphore_liste_threads);
                           return;
                       }
   
                       pthread_mutex_destroy(&((*s_argument_thread).mutex));
   
                       if ((*s_argument_thread).processus_detache == d_faux)
                       {
                           if ((*s_argument_thread).destruction_objet == d_vrai)
                           {
                               liberation(s_etat_processus, (*s_argument_thread)
                                       .argument);
                           }
                       }
   
                       free(s_argument_thread);
                   }
                   else
                   {
                       if (pthread_mutex_unlock(&((*s_argument_thread).mutex))
                               != 0)
                       {
                           (*s_etat_processus).erreur_systeme = d_es_processus;
                           sem_post(&semaphore_liste_threads);
                           return;
                       }
                   }
   
                 element_suivant = (*((struct_liste_chainee *) element_courant))                  element_suivant = (*((struct_liste_chainee *) element_courant))
                         .suivant;                          .suivant;
                 free((struct_liste_chainee *) element_courant);                  free(element_courant);
                 element_courant = element_suivant;                  element_courant = element_suivant;
             }              }
   
               (*s_etat_processus).l_base_pile_processus = NULL;
   
             pthread_mutex_trylock(&((*(*s_etat_processus).indep).mutex));              pthread_mutex_trylock(&((*(*s_etat_processus).indep).mutex));
             pthread_mutex_unlock(&((*(*s_etat_processus).indep).mutex));              pthread_mutex_unlock(&((*(*s_etat_processus).indep).mutex));
             liberation(s_etat_processus, (*s_etat_processus).indep);              liberation(s_etat_processus, (*s_etat_processus).indep);
Line 1291  liberation_threads(struct_processus *s_e Line 1350  liberation_threads(struct_processus *s_e
         s_argument_thread = (struct_descripteur_thread *)          s_argument_thread = (struct_descripteur_thread *)
                 (*l_element_courant).donnee;                  (*l_element_courant).donnee;
   
         close((*s_argument_thread).pipe_objets[0]);  
         close((*s_argument_thread).pipe_acquittement[1]);  
         close((*s_argument_thread).pipe_injections[1]);  
         close((*s_argument_thread).pipe_nombre_injections[1]);  
         close((*s_argument_thread).pipe_nombre_objets_attente[0]);  
         close((*s_argument_thread).pipe_interruptions[0]);  
         close((*s_argument_thread).pipe_nombre_interruptions_attente[0]);  
   
         if (pthread_mutex_lock(&((*s_argument_thread).mutex)) != 0)          if (pthread_mutex_lock(&((*s_argument_thread).mutex)) != 0)
         {          {
             (*s_etat_processus).erreur_systeme = d_es_processus;              (*s_etat_processus).erreur_systeme = d_es_processus;
Line 1314  liberation_threads(struct_processus *s_e Line 1365  liberation_threads(struct_processus *s_e
   
         if ((*s_argument_thread).nombre_references == 0)          if ((*s_argument_thread).nombre_references == 0)
         {          {
               close((*s_argument_thread).pipe_objets[0]);
               close((*s_argument_thread).pipe_acquittement[1]);
               close((*s_argument_thread).pipe_injections[1]);
               close((*s_argument_thread).pipe_nombre_injections[1]);
               close((*s_argument_thread).pipe_nombre_objets_attente[0]);
               close((*s_argument_thread).pipe_interruptions[0]);
               close((*s_argument_thread).pipe_nombre_interruptions_attente[0]);
   
             if (pthread_mutex_unlock(&((*s_argument_thread).mutex)) != 0)              if (pthread_mutex_unlock(&((*s_argument_thread).mutex)) != 0)
             {              {
                 (*s_etat_processus).erreur_systeme = d_es_processus;                  (*s_etat_processus).erreur_systeme = d_es_processus;
Line 1322  liberation_threads(struct_processus *s_e Line 1381  liberation_threads(struct_processus *s_e
             }              }
   
             pthread_mutex_destroy(&((*s_argument_thread).mutex));              pthread_mutex_destroy(&((*s_argument_thread).mutex));
   
               if ((*s_argument_thread).processus_detache == d_faux)
               {
                   if ((*s_argument_thread).destruction_objet == d_vrai)
                   {
                       liberation(s_etat_processus, (*s_argument_thread).argument);
                   }
               }
   
             free(s_argument_thread);              free(s_argument_thread);
         }          }
         else          else
Line 1657  deverrouillage_gestionnaire_signaux() Line 1725  deverrouillage_gestionnaire_signaux()
 }  }
   
 void  void
 interruption1(int signal, siginfo_t *siginfo, void *context)  interruption1(SIGHANDLER_ARGS)
 {  {
       pid_t                   pid;
   
     pthread_t               thread;      pthread_t               thread;
   
     struct_processus        *s_etat_processus;      struct_processus        *s_etat_processus;
Line 1667  interruption1(int signal, siginfo_t *sig Line 1737  interruption1(int signal, siginfo_t *sig
   
     verrouillage_gestionnaire_signaux();      verrouillage_gestionnaire_signaux();
   
   #   ifdef _BROKEN_SIGINFO
       if (signal == SIGINT)
       {
           // Si l'interruption provient du clavier, il n'y a pas eu d'appel
           // à queue_in().
   
           pid = getpid();
       }
       else
       {
           pid = origine_signal(signal);
       }
   #   else
       pid = (*siginfo).si_pid;
   #   endif
   
     switch(signal)      switch(signal)
     {      {
         case SIGALRM :          case SIGALRM :
         {          {
             if ((*siginfo).si_pid == getpid())              if (pid == getpid())
             {              {
                 if ((s_etat_processus = recherche_thread(getpid(),                  if ((s_etat_processus = recherche_thread(getpid(),
                         pthread_self())) == NULL)                          pthread_self())) == NULL)
                 {                  {
                     deverrouillage_gestionnaire_signaux();                      deverrouillage_gestionnaire_signaux();
                     return;                       return;
                 }                  }
   
                 if (((*s_etat_processus).type_debug & d_debug_signaux) != 0)                  if (((*s_etat_processus).type_debug & d_debug_signaux) != 0)
Line 1716  interruption1(int signal, siginfo_t *sig Line 1802  interruption1(int signal, siginfo_t *sig
              * Solaris suit en particulier cette spécification.               * Solaris suit en particulier cette spécification.
              */               */
   
   #           ifndef _BROKEN_SIGINFO
             if (siginfo == NULL)              if (siginfo == NULL)
             {              {
                 kill(getpid(), signal);                  kill(getpid(), signal);
             }              }
             else if ((*siginfo).si_pid == getpid())              else
   #           endif
               if (pid == getpid())
             {              {
                 if ((s_etat_processus = recherche_thread(getpid(),                  if ((s_etat_processus = recherche_thread(getpid(),
                         pthread_self())) == NULL)                          pthread_self())) == NULL)
Line 1795  interruption1(int signal, siginfo_t *sig Line 1884  interruption1(int signal, siginfo_t *sig
 }  }
   
 void  void
 interruption2(int signal, siginfo_t *siginfo, void *context)  interruption2(SIGHANDLER_ARGS)
 {  {
       pid_t                   pid;
   
     pthread_t               thread;      pthread_t               thread;
   
     struct_processus        *s_etat_processus;      struct_processus        *s_etat_processus;
   
     verrouillage_gestionnaire_signaux();      verrouillage_gestionnaire_signaux();
   
   #   ifdef _BROKEN_SIGINFO
       pid = origine_signal(signal);
   #   else
       pid = (*siginfo).si_pid;
   #   endif
   
   #   ifndef _BROKEN_SIGINFO
     if (siginfo == NULL)      if (siginfo == NULL)
     {      {
         /*          /*
Line 1819  interruption2(int signal, siginfo_t *sig Line 1918  interruption2(int signal, siginfo_t *sig
             return;              return;
         }          }
     }      }
     else if ((*siginfo).si_pid == getpid())      else
   #   endif
       if (pid == getpid())
     {      {
         if ((s_etat_processus = recherche_thread(getpid(), pthread_self()))          if ((s_etat_processus = recherche_thread(getpid(), pthread_self()))
                 == NULL)                  == NULL)
Line 1867  interruption2(int signal, siginfo_t *sig Line 1968  interruption2(int signal, siginfo_t *sig
 }  }
   
 void  void
 interruption3(int signal, siginfo_t *siginfo, void *context)  interruption3(SIGHANDLER_ARGS)
 {  {
       pid_t                   pid;
   
     struct_processus        *s_etat_processus;      struct_processus        *s_etat_processus;
   
     static int              compteur = 0;      static int              compteur = 0;
   
     verrouillage_gestionnaire_signaux();      verrouillage_gestionnaire_signaux();
   
   #   ifdef _BROKEN_SIGINFO
       pid = origine_signal(signal);
   #   else
       pid = (*siginfo).si_pid;
   #   endif
   
     if ((s_etat_processus = recherche_thread(getpid(), pthread_self())) == NULL)      if ((s_etat_processus = recherche_thread(getpid(), pthread_self())) == NULL)
     {      {
         deverrouillage_gestionnaire_signaux();          deverrouillage_gestionnaire_signaux();
Line 1927  interruption3(int signal, siginfo_t *sig Line 2036  interruption3(int signal, siginfo_t *sig
 }  }
   
 void  void
 interruption4(int signal, siginfo_t *siginfo, void *context)  interruption4(SIGHANDLER_ARGS)
 {  {
       pid_t                   pid;
   
     struct_processus        *s_etat_processus;      struct_processus        *s_etat_processus;
   
     verrouillage_gestionnaire_signaux();      verrouillage_gestionnaire_signaux();
   
   #   ifdef _BROKEN_SIGINFO
       pid = origine_signal(signal);
   #   else
       pid = (*siginfo).si_pid;
   #   endif
   
     if ((s_etat_processus = recherche_thread(getpid(), pthread_self())) == NULL)      if ((s_etat_processus = recherche_thread(getpid(), pthread_self())) == NULL)
     {      {
         deverrouillage_gestionnaire_signaux();          deverrouillage_gestionnaire_signaux();
Line 1955  interruption4(int signal, siginfo_t *sig Line 2072  interruption4(int signal, siginfo_t *sig
 }  }
   
 void  void
 interruption5(int signal, siginfo_t *siginfo, void *context)  interruption5(SIGHANDLER_ARGS)
 {  {
       pid_t                   pid;
   
     pthread_t               thread;      pthread_t               thread;
   
     struct_processus        *s_etat_processus;      struct_processus        *s_etat_processus;
   
     verrouillage_gestionnaire_signaux();      verrouillage_gestionnaire_signaux();
   
     if ((*siginfo).si_pid == getpid())  #   ifdef _BROKEN_SIGINFO
       pid = origine_signal(signal);
   #   else
       pid = (*siginfo).si_pid;
   #   endif
   
       if (pid == getpid())
     {      {
         if ((s_etat_processus = recherche_thread(getpid(), pthread_self()))          if ((s_etat_processus = recherche_thread(getpid(), pthread_self()))
                 == NULL)                  == NULL)
Line 2018  interruption5(int signal, siginfo_t *sig Line 2144  interruption5(int signal, siginfo_t *sig
 }  }
   
 void  void
 interruption6(int signal, siginfo_t *siginfo, void *context)  interruption6(SIGHANDLER_ARGS)
 {  {
       pid_t                   pid;
   
     struct_processus        *s_etat_processus;      struct_processus        *s_etat_processus;
   
     verrouillage_gestionnaire_signaux();      verrouillage_gestionnaire_signaux();
   
   #   ifdef _BROKEN_SIGINFO
       pid = origine_signal(signal);
   #   else
       pid = (*siginfo).si_pid;
   #   endif
   
     if ((s_etat_processus = recherche_thread(getpid(), pthread_self())) == NULL)      if ((s_etat_processus = recherche_thread(getpid(), pthread_self())) == NULL)
     {      {
         deverrouillage_gestionnaire_signaux();          deverrouillage_gestionnaire_signaux();
Line 2042  interruption6(int signal, siginfo_t *sig Line 2176  interruption6(int signal, siginfo_t *sig
 }  }
   
 void  void
 interruption7(int signal, siginfo_t *siginfo, void *context)  interruption7(SIGHANDLER_ARGS)
 {  {
       pid_t                   pid;
   
     struct_processus        *s_etat_processus;      struct_processus        *s_etat_processus;
   
     verrouillage_gestionnaire_signaux();      verrouillage_gestionnaire_signaux();
   
   #   ifdef _BROKEN_SIGINFO
       pid = origine_signal(signal);
   #   else
       pid = (*siginfo).si_pid;
   #   endif
   
     if ((s_etat_processus = recherche_thread(getpid(), pthread_self())) == NULL)      if ((s_etat_processus = recherche_thread(getpid(), pthread_self())) == NULL)
     {      {
         deverrouillage_gestionnaire_signaux();          deverrouillage_gestionnaire_signaux();
Line 2069  interruption7(int signal, siginfo_t *sig Line 2211  interruption7(int signal, siginfo_t *sig
 }  }
   
 void  void
 interruption8(int signal, siginfo_t *siginfo, void *context)  interruption8(SIGHANDLER_ARGS)
 {  {
       pid_t                   pid;
   
     pthread_t               thread;      pthread_t               thread;
   
     struct_processus        *s_etat_processus;      struct_processus        *s_etat_processus;
   
     verrouillage_gestionnaire_signaux();      verrouillage_gestionnaire_signaux();
   
     if ((*siginfo).si_pid == getpid())  #   ifdef _BROKEN_SIGINFO
       pid = origine_signal(signal);
   #   else
       pid = (*siginfo).si_pid;
   #   endif
   
       if (pid == getpid())
     {      {
         if ((s_etat_processus = recherche_thread(getpid(), pthread_self()))          if ((s_etat_processus = recherche_thread(getpid(), pthread_self()))
                 == NULL)                  == NULL)
Line 2112  interruption8(int signal, siginfo_t *sig Line 2263  interruption8(int signal, siginfo_t *sig
 }  }
   
 void  void
 interruption9(int signal, siginfo_t *siginfo, void *context)  interruption9(SIGHANDLER_ARGS)
 {  {
       pid_t                   pid;
   
     struct_processus        *s_etat_processus;      struct_processus        *s_etat_processus;
   
     verrouillage_gestionnaire_signaux();      verrouillage_gestionnaire_signaux();
   
   #   ifdef _BROKEN_SIGINFO
       pid = origine_signal(signal);
   #   else
       pid = (*siginfo).si_pid;
   #   endif
   
     if ((s_etat_processus = recherche_thread(getpid(), pthread_self())) == NULL)      if ((s_etat_processus = recherche_thread(getpid(), pthread_self())) == NULL)
     {      {
         deverrouillage_gestionnaire_signaux();          deverrouillage_gestionnaire_signaux();
Line 2131  interruption9(int signal, siginfo_t *sig Line 2290  interruption9(int signal, siginfo_t *sig
         fflush(stdout);          fflush(stdout);
     }      }
   
   #   ifdef _BROKEN_SIGINFO
       if (queue_in(getpid(), signal) != 0)
       {
           return;
       }
   
       deverrouillage_gestionnaire_signaux();
       interruption11(signal);
   #   else
     deverrouillage_gestionnaire_signaux();      deverrouillage_gestionnaire_signaux();
     interruption11(signal, siginfo, context);      interruption11(signal, siginfo, context);
   #   endif
     return;      return;
 }  }
   
 void  void
 interruption10(int signal, siginfo_t *siginfo, void *context)  interruption10(SIGHANDLER_ARGS)
 {  {
     file                    *fichier;      file                    *fichier;
   
       pid_t                   pid;
   
     struct_processus        *s_etat_processus;      struct_processus        *s_etat_processus;
   
     unsigned char           nom[8 + 64 + 1];      unsigned char           nom[8 + 64 + 1];
   
     verrouillage_gestionnaire_signaux();      verrouillage_gestionnaire_signaux();
   
   #   ifdef _BROKEN_SIGINFO
       pid = origine_signal(signal);
   #   else
       pid = (*siginfo).si_pid;
   #   endif
   
     if ((s_etat_processus = recherche_thread(getpid(), pthread_self())) == NULL)      if ((s_etat_processus = recherche_thread(getpid(), pthread_self())) == NULL)
     {      {
         deverrouillage_gestionnaire_signaux();          deverrouillage_gestionnaire_signaux();
Line 2178  interruption10(int signal, siginfo_t *si Line 2355  interruption10(int signal, siginfo_t *si
 }  }
   
 void  void
 interruption11(int signal, siginfo_t *siginfo, void *context)  interruption11(SIGHANDLER_ARGS)
 {  {
       pid_t                   pid;
   
     pthread_t               thread;      pthread_t               thread;
   
     struct_processus        *s_etat_processus;      struct_processus        *s_etat_processus;
   
     verrouillage_gestionnaire_signaux();      verrouillage_gestionnaire_signaux();
   
     if ((*siginfo).si_pid == getpid())  #   ifdef _BROKEN_SIGINFO
       pid = origine_signal(signal);
   #   else
       pid = (*siginfo).si_pid;
   #   endif
   
       if (pid == getpid())
     {      {
         if ((s_etat_processus = recherche_thread(getpid(), pthread_self()))          if ((s_etat_processus = recherche_thread(getpid(), pthread_self()))
                 == NULL)                  == NULL)

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


CVSweb interface <joel.bertrand@systella.fr>