--- rpl/src/interruptions.c 2012/05/21 17:25:45 1.98 +++ rpl/src/interruptions.c 2012/10/09 15:27:45 1.105 @@ -1,6 +1,6 @@ /* ================================================================================ - RPL/2 (R) version 4.1.9 + RPL/2 (R) version 4.1.11 Copyright (C) 1989-2012 Dr. BERTRAND Joël This file is part of RPL/2. @@ -88,7 +88,7 @@ thread_surveillance_signaux(void *argume attente.tv_sec = 0; attente.tv_nsec = GRANULARITE_us * 1000; -# ifndef SEMAPHORES_NOMMES +# if (!defined(SEMAPHORES_NOMMES)) || defined(IPCS_SYSV) if (sem_wait(&(*s_queue_signaux).signalisation) == 0) # else if(sem_wait(semaphore_signalisation) == 0) @@ -99,7 +99,7 @@ thread_surveillance_signaux(void *argume break; } -# ifndef SEMAPHORES_NOMMES +# if (!defined(SEMAPHORES_NOMMES)) || defined(IPCS_SYSV) sem_post(&(*s_queue_signaux).signalisation); # else sem_post(semaphore_signalisation); @@ -112,7 +112,7 @@ thread_surveillance_signaux(void *argume // affectée au processus courant pour vérifier s'il y a quelque // chose à traiter. -# ifndef SEMAPHORES_NOMMES +# if (!defined(SEMAPHORES_NOMMES)) || defined(IPCS_SYSV) sem_wait(&(*s_queue_signaux).semaphore); # else sem_wait(semaphore_queue_signaux); @@ -125,7 +125,7 @@ thread_surveillance_signaux(void *argume raise(SIGALRM); } -# ifndef SEMAPHORES_NOMMES +# if (!defined(SEMAPHORES_NOMMES)) || defined(IPCS_SYSV) sem_post(&(*s_queue_signaux).semaphore); # else sem_post(semaphore_queue_signaux); @@ -325,7 +325,7 @@ retrait_thread(struct_processus *s_etat_ (*l_element_courant).donnee)).s_etat_processus) .pointeur_signal_lecture) { -# ifndef SEMAPHORES_NOMMES +# if (!defined(SEMAPHORES_NOMMES)) || defined(IPCS_SYSV) sem_wait(&((*s_queue_signaux).signalisation)); # else sem_wait(semaphore_signalisation); @@ -746,20 +746,6 @@ liberation_threads(struct_processus *s_e liberation_arbre_variables(s_etat_processus, (*s_etat_processus).s_arbre_variables, d_faux); - for(i = 0; i < (*s_etat_processus).nombre_variables_statiques; i++) - { - pthread_mutex_trylock(&((*(*s_etat_processus) - .s_liste_variables_statiques[i].objet).mutex)); - pthread_mutex_unlock(&((*(*s_etat_processus) - .s_liste_variables_statiques[i].objet).mutex)); - - liberation(s_etat_processus, (*s_etat_processus) - .s_liste_variables_statiques[i].objet); - free((*s_etat_processus).s_liste_variables_statiques[i].nom); - } - - free((*s_etat_processus).s_liste_variables_statiques); - // Ne peut être effacé qu'une seule fois if (suppression_variables_partagees == d_faux) { @@ -1622,7 +1608,7 @@ deverrouillage_gestionnaire_signaux(stru if (signal_test == SIGTEST) { signal_test = signal; return; } // Récupération des signaux -// - SIGINT (arrêt au clavier) +// - SIGINT (arrêt au clavier) // - SIGTERM (signal d'arrêt en provenance du système) void @@ -1643,6 +1629,10 @@ interruption1(int signal) case SIGUSR1: envoi_signal_processus(getpid(), rpl_sigalrm); break; + + default: + // SIGALRM + break; } return; @@ -2397,7 +2387,7 @@ scrutation_interruptions(struct_processu // à lire. Les pointeurs d'écriture pointent sur les prochains éléments à // écrire. -# ifndef SEMAPHORES_NOMMES +# if (!defined(SEMAPHORES_NOMMES)) || defined(IPCS_SYSV) if (sem_trywait(&((*s_queue_signaux).semaphore)) == 0) # else if (sem_trywait(semaphore_queue_signaux) == 0) @@ -2417,14 +2407,14 @@ scrutation_interruptions(struct_processu ((*s_queue_signaux).pointeur_lecture + 1) % LONGUEUR_QUEUE_SIGNAUX; -# ifndef SEMAPHORES_NOMMES +# if (!defined(SEMAPHORES_NOMMES)) || defined(IPCS_SYSV) sem_wait(&((*s_queue_signaux).signalisation)); # else sem_wait(semaphore_signalisation); # endif } -# ifndef SEMAPHORES_NOMMES +# if (!defined(SEMAPHORES_NOMMES)) || defined(IPCS_SYSV) sem_post(&((*s_queue_signaux).semaphore)); # else sem_post(semaphore_queue_signaux); @@ -2448,7 +2438,7 @@ scrutation_interruptions(struct_processu ((*s_etat_processus).pointeur_signal_lecture + 1) % LONGUEUR_QUEUE_SIGNAUX; -# ifndef SEMAPHORES_NOMMES +# if (!defined(SEMAPHORES_NOMMES)) || defined(IPCS_SYSV) sem_wait(&((*s_queue_signaux).signalisation)); # else sem_wait(semaphore_signalisation); @@ -2560,7 +2550,7 @@ envoi_signal_processus(pid_t pid, enum s return(1); } -# ifndef SEMAPHORES_NOMMES +# if (!defined(SEMAPHORES_NOMMES)) || defined(IPCS_SYSV) while(sem_wait(&((*s_queue_signaux).semaphore)) != 0) # else while(sem_wait(semaphore_queue_signaux) != 0) @@ -2581,7 +2571,7 @@ envoi_signal_processus(pid_t pid, enum s ((*s_queue_signaux).pointeur_ecriture + 1) % LONGUEUR_QUEUE_SIGNAUX; -# ifndef SEMAPHORES_NOMMES +# if (!defined(SEMAPHORES_NOMMES)) || defined(IPCS_SYSV) if (sem_post(&((*s_queue_signaux).semaphore)) != 0) # else if (sem_post(semaphore_queue_signaux) != 0) @@ -2590,7 +2580,7 @@ envoi_signal_processus(pid_t pid, enum s return(1); } -# ifndef SEMAPHORES_NOMMES +# if (!defined(SEMAPHORES_NOMMES)) || defined(IPCS_SYSV) if (sem_post(&((*s_queue_signaux).signalisation)) != 0) # else if (sem_post(semaphore_signalisation) != 0) @@ -2843,7 +2833,7 @@ envoi_signal_thread(pthread_t tid, enum return(1); } -# ifndef SEMAPHORES_NOMMES +# if (!defined(SEMAPHORES_NOMMES)) || defined(IPCS_SYSV) if (sem_post(&((*s_queue_signaux).signalisation)) != 0) { return(1); @@ -2871,7 +2861,7 @@ envoi_signal_contexte(struct_processus * % LONGUEUR_QUEUE_SIGNAUX; pthread_mutex_unlock(&mutex_interruptions); -# ifndef SEMAPHORES_NOMMES +# if (!defined(SEMAPHORES_NOMMES)) || defined(IPCS_SYSV) if (sem_post(&((*s_queue_signaux).signalisation)) != 0) { return(1); @@ -3142,7 +3132,7 @@ liberation_queue_signaux(struct_processu (*s_queue_signaux).requete_arret = d_vrai; -# ifndef SEMAPHORES_NOMMES +# if (!defined(SEMAPHORES_NOMMES)) || defined(IPCS_SYSV) sem_post(&((*s_queue_signaux).signalisation)); # else sem_post(semaphore_signalisation); @@ -3201,6 +3191,18 @@ destruction_queue_signaux(struct_process unsigned char *nom; # endif + // Incrémenter le sémaphore pour être sûr de le débloquer. + + (*s_queue_signaux).requete_arret = d_vrai; + +# if (!defined(SEMAPHORES_NOMMES)) || defined(IPCS_SYSV) + sem_post(&((*s_queue_signaux).signalisation)); +# else + sem_post(semaphore_signalisation); +# endif + + pthread_join((*s_queue_signaux).thread_signaux, NULL); + # ifdef IPCS_SYSV // SystemV # ifndef OS2 // Il faut commencer par éliminer le sémaphore.