Diff for /rpl/src/instructions_w1.c between versions 1.110 and 1.119

version 1.110, 2018/06/01 09:57:28 version 1.119, 2019/10/31 15:40:22
Line 1 Line 1
 /*  /*
 ================================================================================  ================================================================================
   RPL/2 (R) version 4.1.29    RPL/2 (R) version 4.1.32
   Copyright (C) 1989-2018 Dr. BERTRAND Joël    Copyright (C) 1989-2019 Dr. BERTRAND Joël
   
   This file is part of RPL/2.    This file is part of RPL/2.
   
Line 1732  instruction_write(struct_processus *s_et Line 1732  instruction_write(struct_processus *s_et
                 (*s_objet_argument_1).objet)).type,                  (*s_objet_argument_1).objet)).type,
                 "SEQUENTIAL DATAGRAM") == 0))                  "SEQUENTIAL DATAGRAM") == 0))
         { // Sockets connectées          { // Sockets connectées
   
             action.sa_handler = SIG_IGN;  
             action.sa_flags = SA_ONSTACK;  
   
             if (sigaction(SIGPIPE, &action, &registre) != 0)  
             {  
                 (*s_etat_processus).erreur_systeme = d_es_signal;  
                 return;  
             }  
   
 #           ifndef SEMAPHORES_NOMMES  #           ifndef SEMAPHORES_NOMMES
                 if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)                  if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 #           else  #           else
                 if (sem_post((*s_etat_processus).semaphore_fork) != 0)                  if (sem_post((*s_etat_processus).semaphore_fork) != 0)
 #           endif  #           endif
             {              {
                 if (sigaction(SIGPIPE, &registre, NULL) != 0)                  (*s_etat_processus).erreur_systeme = d_es_processus;
                 {                  return;
                     (*s_etat_processus).erreur_systeme = d_es_signal;              }
                     return;  
                 }  
   
               if (pthread_mutex_lock(&mutex_sigaction) != 0)
               {
                 (*s_etat_processus).erreur_systeme = d_es_processus;                  (*s_etat_processus).erreur_systeme = d_es_processus;
                 return;                  return;
             }              }
   
               action.sa_handler = SIG_IGN;
               action.sa_flags = 0;
   
               if (sigaction(SIGPIPE, &action, &registre) != 0)
               {
                   pthread_mutex_unlock(&mutex_sigaction);
                   (*s_etat_processus).erreur_systeme = d_es_signal;
                   return;
               }
   
             if (send((*((struct_socket *) (*s_objet_argument_1).objet))              if (send((*((struct_socket *) (*s_objet_argument_1).objet))
                     .socket, chaine, (size_t) longueur_effective, 0) < 0)                      .socket, chaine, (size_t) longueur_effective, 0) < 0)
             {              {
Line 1765  instruction_write(struct_processus *s_et Line 1765  instruction_write(struct_processus *s_et
   
                 if (sigaction(SIGPIPE, &registre, NULL) != 0)                  if (sigaction(SIGPIPE, &registre, NULL) != 0)
                 {                  {
                       pthread_mutex_unlock(&mutex_sigaction);
                     (*s_etat_processus).erreur_systeme = d_es_signal;                      (*s_etat_processus).erreur_systeme = d_es_signal;
                     return;                      return;
                 }                  }
   
                   if (pthread_mutex_unlock(&mutex_sigaction) != 0)
                   {
                       (*s_etat_processus).erreur_systeme = d_es_processus;
                       return;
                   }
   
 #               ifndef SEMAPHORES_NOMMES  #               ifndef SEMAPHORES_NOMMES
                     while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)                      while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
 #               else  #               else
Line 1793  instruction_write(struct_processus *s_et Line 1800  instruction_write(struct_processus *s_et
                 return;                  return;
             }              }
   
               if (sigaction(SIGPIPE, &registre, 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, &registre, 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  #           ifndef SEMAPHORES_NOMMES
                 while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)                  while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
 #           else  #           else
Line 1811  instruction_write(struct_processus *s_et Line 1853  instruction_write(struct_processus *s_et
                     return;                      return;
                 }                  }
             }              }
   
             if (sigaction(SIGPIPE, &registre, NULL) != 0)  
             {  
                 (*s_etat_processus).erreur_systeme = d_es_signal;  
                 return;  
             }  
         }          }
         else          else
         { // Sockets non connectées          { // Sockets non connectées
Line 2292  instruction_wflock(struct_processus *s_e Line 2328  instruction_wflock(struct_processus *s_e
                 return;                  return;
             }              }
   
 #           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;  
             }  
   
 #           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)  
                 {  
                     (*s_etat_processus).erreur_systeme = d_es_processus;  
                     return;  
                 }  
             }  
   
             if (lock.l_type == F_UNLCK)              if (lock.l_type == F_UNLCK)
             {              {
                 drapeau = d_vrai;                  drapeau = d_vrai;
Line 2350  instruction_wflock(struct_processus *s_e Line 2363  instruction_wflock(struct_processus *s_e
                             registre_instruction_valide;                              registre_instruction_valide;
                 }                  }
   
                 nanosleep(&attente, NULL);  
                 scrutation_injection(s_etat_processus);                  scrutation_injection(s_etat_processus);
   
   #               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;
                   }
   
                   nanosleep(&attente, NULL);
   
                 INCR_GRANULARITE(attente.tv_nsec);                  INCR_GRANULARITE(attente.tv_nsec);
   
   #               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)
                       {
                           (*s_etat_processus).erreur_systeme = d_es_processus;
                           return;
                       }
                   }
             }              }
         } while((drapeau == d_faux) && ((*s_etat_processus)          } while((drapeau == d_faux) && ((*s_etat_processus)
                 .var_volatile_requete_arret != -1));                  .var_volatile_requete_arret != -1));
Line 3201  instruction_wfsock(struct_processus *s_e Line 3238  instruction_wfsock(struct_processus *s_e
     struct sockaddr_in6     adresse_ipv6;      struct sockaddr_in6     adresse_ipv6;
 #   endif  #   endif
   
     unsigned long           i;  
   
     if ((*s_etat_processus).affichage_arguments == 'Y')      if ((*s_etat_processus).affichage_arguments == 'Y')
     {      {
         printf("\n  WFSOCK ");          printf("\n  WFSOCK ");
Line 3566  instruction_wfsock(struct_processus *s_e Line 3601  instruction_wfsock(struct_processus *s_e
                 } while(drapeau == d_faux);                  } while(drapeau == d_faux);
   
                 if (((*((struct_socket *) (*s_objet_resultat).objet))                  if (((*((struct_socket *) (*s_objet_resultat).objet))
                         .adresse_distante = malloc(55 *                          .adresse_distante = malloc(47 *
                         sizeof(unsigned char))) == NULL)                          sizeof(unsigned char))) == NULL)
                 {                  {
                     (*s_etat_processus).erreur_systeme =                      (*s_etat_processus).erreur_systeme =
Line 3574  instruction_wfsock(struct_processus *s_e Line 3609  instruction_wfsock(struct_processus *s_e
                     return;                      return;
                 }                  }
   
                 (*((struct_socket *) (*s_objet_resultat).objet))  
                         .adresse_distante = d_code_fin_chaine;  
   
                 for(i = 0; i < 16; i++)  
                 {  
                     sprintf((*((struct_socket *) (*s_objet_resultat)  
                             .objet)).adresse_distante, (i == 0) ? "%s%X"  
                             : "%s:%X", (*((struct_socket *) (*s_objet_resultat)  
                             .objet)).adresse_distante,  
                             adresse_ipv6.sin6_addr.s6_addr[i]);  
                 }  
   
                 sprintf((*((struct_socket *) (*s_objet_resultat)                  sprintf((*((struct_socket *) (*s_objet_resultat)
                         .objet)).adresse_distante, "%s(%u)",  
                         (*((struct_socket *) (*s_objet_resultat)  
                         .objet)).adresse_distante,                          .objet)).adresse_distante,
                           "%02X%02X:%02X%02X:%02X%02X:%02X%02X:"
                           "%02X%02X:%02X%02X:%02X%02X:%02X%02X(%u)",
                           adresse_ipv6.sin6_addr.s6_addr[0],
                           adresse_ipv6.sin6_addr.s6_addr[1],
                           adresse_ipv6.sin6_addr.s6_addr[2],
                           adresse_ipv6.sin6_addr.s6_addr[3],
                           adresse_ipv6.sin6_addr.s6_addr[4],
                           adresse_ipv6.sin6_addr.s6_addr[5],
                           adresse_ipv6.sin6_addr.s6_addr[6],
                           adresse_ipv6.sin6_addr.s6_addr[7],
                           adresse_ipv6.sin6_addr.s6_addr[8],
                           adresse_ipv6.sin6_addr.s6_addr[9],
                           adresse_ipv6.sin6_addr.s6_addr[10],
                           adresse_ipv6.sin6_addr.s6_addr[11],
                           adresse_ipv6.sin6_addr.s6_addr[12],
                           adresse_ipv6.sin6_addr.s6_addr[13],
                           adresse_ipv6.sin6_addr.s6_addr[14],
                           adresse_ipv6.sin6_addr.s6_addr[15],
                         ntohs(adresse_ipv6.sin6_port));                          ntohs(adresse_ipv6.sin6_port));
 #           else  #           else
                 if ((*s_etat_processus).langue == 'F')                  if ((*s_etat_processus).langue == 'F')
Line 3890  instruction_wfswi(struct_processus *s_et Line 3929  instruction_wfswi(struct_processus *s_et
             }              }
             else              else
             {              {
   #               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;
                   }
                 nanosleep(&attente, NULL);                  nanosleep(&attente, NULL);
   
   #               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)
                       {
                           (*s_etat_processus).erreur_systeme = d_es_processus;
                           return;
                       }
                   }
   
                 scrutation_injection(s_etat_processus);                  scrutation_injection(s_etat_processus);
                 INCR_GRANULARITE(attente.tv_nsec);                  INCR_GRANULARITE(attente.tv_nsec);
             }              }

Removed from v.1.110  
changed lines
  Added in v.1.119


CVSweb interface <joel.bertrand@systella.fr>