--- rpl/src/instructions_w1.c 2019/02/11 09:45:52 1.116 +++ rpl/src/instructions_w1.c 2019/02/12 14:38:43 1.117 @@ -1732,6 +1732,16 @@ instruction_write(struct_processus *s_et (*s_objet_argument_1).objet)).type, "SEQUENTIAL DATAGRAM") == 0)) { // Sockets connectées +# ifndef SEMAPHORES_NOMMES + if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) +# else + if (sem_post((*s_etat_processus).semaphore_fork) != 0) +# endif + { + (*s_etat_processus).erreur_systeme = d_es_processus; + return; + } + if (pthread_mutex_lock(&mutex_sigaction) != 0) { (*s_etat_processus).erreur_systeme = d_es_processus; @@ -1748,24 +1758,6 @@ instruction_write(struct_processus *s_et return; } -# ifndef SEMAPHORES_NOMMES - if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) -# else - if (sem_post((*s_etat_processus).semaphore_fork) != 0) -# endif - { - if (sigaction(SIGPIPE, ®istre, NULL) != 0) - { - pthread_mutex_unlock(&mutex_sigaction); - (*s_etat_processus).erreur_systeme = d_es_signal; - return; - } - - pthread_mutex_unlock(&mutex_sigaction); - (*s_etat_processus).erreur_systeme = d_es_processus; - return; - } - if (send((*((struct_socket *) (*s_objet_argument_1).objet)) .socket, chaine, (size_t) longueur_effective, 0) < 0) { @@ -1808,6 +1800,41 @@ instruction_write(struct_processus *s_et return; } + if (sigaction(SIGPIPE, ®istre, NULL) != 0) + { + pthread_mutex_unlock(&mutex_sigaction); + +# ifndef SEMAPHORES_NOMMES + while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0) +# else + while(sem_wait((*s_etat_processus).semaphore_fork) != 0) +# endif + { + if (errno != EINTR) + { + if (sigaction(SIGPIPE, ®istre, NULL) != 0) + { + pthread_mutex_unlock(&mutex_sigaction); + (*s_etat_processus).erreur_systeme = d_es_signal; + return; + } + + pthread_mutex_unlock(&mutex_sigaction); + (*s_etat_processus).erreur_systeme = d_es_processus; + return; + } + } + + (*s_etat_processus).erreur_systeme = d_es_signal; + return; + } + + if (pthread_mutex_unlock(&mutex_sigaction) != 0) + { + (*s_etat_processus).erreur_systeme = d_es_processus; + return; + } + # ifndef SEMAPHORES_NOMMES while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0) # else @@ -1818,29 +1845,14 @@ instruction_write(struct_processus *s_et { if (sigaction(SIGPIPE, ®istre, NULL) != 0) { - pthread_mutex_unlock(&mutex_sigaction); (*s_etat_processus).erreur_systeme = d_es_signal; return; } - pthread_mutex_unlock(&mutex_sigaction); (*s_etat_processus).erreur_systeme = d_es_processus; return; } } - - if (sigaction(SIGPIPE, ®istre, NULL) != 0) - { - pthread_mutex_unlock(&mutex_sigaction); - (*s_etat_processus).erreur_systeme = d_es_signal; - return; - } - - if (pthread_mutex_unlock(&mutex_sigaction) != 0) - { - (*s_etat_processus).erreur_systeme = d_es_processus; - return; - } } else { // Sockets non connectées