--- rpl/src/instructions_p8.c 2011/12/05 19:35:54 1.1 +++ rpl/src/instructions_p8.c 2012/03/01 10:14:07 1.7 @@ -1,7 +1,7 @@ /* ================================================================================ - RPL/2 (R) version 4.1.5 - Copyright (C) 1989-2011 Dr. BERTRAND Joël + RPL/2 (R) version 4.1.7 + Copyright (C) 1989-2012 Dr. BERTRAND Joël This file is part of RPL/2. @@ -38,6 +38,7 @@ void instruction_poll(struct_processus *s_etat_processus) { + int erreur; int ios; int timeout; @@ -76,7 +77,7 @@ instruction_poll(struct_processus *s_eta printf(" Usage:\n\n"); } - printf(" FILE { \"POLLIN\" \"POLLOUT\" } TIMEOUT POLL\n"); + printf(" FILE { \"POLLIN\" \"POLLOUT\" } TIMEOUT POLL\n\n"); printf(" 3: %s, %s\n", d_SCK, d_FCH); printf(" 2: %s\n", d_LST); printf(" 1: %s, %s\n", d_INT, d_REL); @@ -108,7 +109,7 @@ instruction_poll(struct_processus *s_eta if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile), &s_objet_argument_2) == d_erreur) { - liberation(s_objet_argument_1); + liberation(s_etat_processus, s_objet_argument_1); (*s_etat_processus).erreur_execution = d_ex_manque_argument; return; @@ -117,8 +118,8 @@ instruction_poll(struct_processus *s_eta if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile), &s_objet_argument_3) == d_erreur) { - liberation(s_objet_argument_1); - liberation(s_objet_argument_2); + liberation(s_etat_processus, s_objet_argument_1); + liberation(s_etat_processus, s_objet_argument_2); (*s_etat_processus).erreur_execution = d_ex_manque_argument; return; @@ -130,12 +131,12 @@ instruction_poll(struct_processus *s_eta if ((*s_objet_argument_3).type == SCK) { s_poll.fd = (*((struct_socket *) - (*s_objet_argument_1).objet)).socket; + (*s_objet_argument_3).objet)).socket; } else { s_poll.fd = (*((struct_fichier *) - (*s_objet_argument_1).objet)).descripteur; + (*s_objet_argument_3).objet)).descripteur; } if ((*s_objet_argument_2).type != LST) @@ -175,7 +176,7 @@ instruction_poll(struct_processus *s_eta { s_poll.events |= POLLIN; } - else (strcmp(registre, "POLLOUT") == 0) + else if (strcmp(registre, "POLLOUT") == 0) { s_poll.events |= POLLOUT; } @@ -218,12 +219,6 @@ instruction_poll(struct_processus *s_eta return; } - if ((s_objet_resultat = allocation(s_etat_processus, INT)) == NULL) - { - (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; - return; - } - do { drapeau = d_vrai; @@ -254,7 +249,6 @@ instruction_poll(struct_processus *s_eta liberation(s_etat_processus, s_objet_argument_1); liberation(s_etat_processus, s_objet_argument_2); liberation(s_etat_processus, s_objet_argument_3); - liberation(s_etat_processus, s_objet_resultat); (*s_etat_processus).erreur_execution = d_ex_erreur_acces_fichier; @@ -291,6 +285,12 @@ instruction_poll(struct_processus *s_eta } } while(drapeau == d_faux); + if ((s_objet_resultat = allocation(s_etat_processus, INT)) == NULL) + { + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + return; + } + if (ios > 0) { // Sortie sur un événement