version 1.65, 2012/07/05 08:05:50
|
version 1.127, 2023/11/24 08:10:19
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.1.9 |
RPL/2 (R) version 4.1.35 |
Copyright (C) 1989-2012 Dr. BERTRAND Joël |
Copyright (C) 1989-2023 Dr. BERTRAND Joël |
|
|
This file is part of RPL/2. |
This file is part of RPL/2. |
|
|
Line 245 instruction_wait(struct_processus *s_eta
|
Line 245 instruction_wait(struct_processus *s_eta
|
return; |
return; |
} |
} |
|
|
temporisation.tv_sec = (long) floor((double) attente); |
temporisation.tv_sec = (time_t) floor((double) attente); |
temporisation.tv_nsec = (attente - temporisation.tv_sec) * |
temporisation.tv_nsec = (long) ((attente - |
(long) 1000000000; |
((real8) temporisation.tv_sec)) * (integer8) 1000000000); |
|
|
if ((*s_etat_processus).profilage == d_vrai) |
if ((*s_etat_processus).profilage == d_vrai) |
{ |
{ |
Line 289 instruction_wait(struct_processus *s_eta
|
Line 289 instruction_wait(struct_processus *s_eta
|
|
|
scrutation_injection(s_etat_processus); |
scrutation_injection(s_etat_processus); |
|
|
|
if (pthread_mutex_lock(&(*s_etat_processus).mutex_interruptions) |
|
!= 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
|
if ((*s_etat_processus).nombre_interruptions_non_affectees != 0) |
if ((*s_etat_processus).nombre_interruptions_non_affectees != 0) |
{ |
{ |
affectation_interruptions_logicielles(s_etat_processus); |
affectation_interruptions_logicielles(s_etat_processus); |
} |
} |
|
|
|
if (pthread_mutex_unlock(&(*s_etat_processus).mutex_interruptions) |
|
!= 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
|
if ((*s_etat_processus).nombre_interruptions_en_queue != 0) |
if ((*s_etat_processus).nombre_interruptions_en_queue != 0) |
{ |
{ |
traitement_interruptions_logicielles(s_etat_processus); |
traitement_interruptions_logicielles(s_etat_processus); |
Line 385 instruction_write(struct_processus *s_et
|
Line 399 instruction_write(struct_processus *s_et
|
|
|
int adresse[16]; |
int adresse[16]; |
int port; |
int port; |
|
int sqlite_status; |
|
|
integer8 clef; |
integer8 clef; |
integer8 compteur; |
integer8 compteur; |
integer8 id; |
integer8 id; |
|
integer8 longueur; |
|
integer8 longueur_effective; |
integer8 ordre; |
integer8 ordre; |
|
integer8 recursivite; |
|
|
logical1 format_degenere; |
logical1 format_degenere; |
|
logical1 format_oriente_ligne; |
logical1 mise_a_jour; |
logical1 mise_a_jour; |
|
|
long longueur; |
|
long longueur_effective; |
|
long recursivite; |
|
|
|
sqlite3_stmt *ppStmt; |
sqlite3_stmt *ppStmt; |
|
|
ssize_t ios; |
ssize_t ios; |
Line 424 instruction_write(struct_processus *s_et
|
Line 439 instruction_write(struct_processus *s_et
|
|
|
struct flock lock; |
struct flock lock; |
|
|
|
struct timespec attente; |
|
|
uint32_t calcul_adresse; |
uint32_t calcul_adresse; |
|
|
unsigned char *chaine; |
unsigned char *chaine; |
Line 589 instruction_write(struct_processus *s_et
|
Line 606 instruction_write(struct_processus *s_et
|
if ((chaine = formateur_fichier(s_etat_processus, |
if ((chaine = formateur_fichier(s_etat_processus, |
s_objet_argument_2, (*((struct_fichier *) |
s_objet_argument_2, (*((struct_fichier *) |
(*s_objet_argument_1).objet)).format, 0, 0, ' ', 'F', |
(*s_objet_argument_1).objet)).format, 0, 0, ' ', 'F', |
&longueur_effective, &recursivite)) == NULL) |
&longueur_effective, &recursivite, d_vrai)) == NULL) |
{ |
{ |
liberation(s_etat_processus, s_objet_argument_2); |
liberation(s_etat_processus, s_objet_argument_2); |
liberation(s_etat_processus, s_objet_argument_1); |
liberation(s_etat_processus, s_objet_argument_1); |
Line 671 instruction_write(struct_processus *s_et
|
Line 688 instruction_write(struct_processus *s_et
|
if ((chaine = formateur_fichier(s_etat_processus, |
if ((chaine = formateur_fichier(s_etat_processus, |
s_objet_argument_3, (*((struct_fichier *) |
s_objet_argument_3, (*((struct_fichier *) |
(*s_objet_argument_1).objet)).format, 0, 0, ' ', |
(*s_objet_argument_1).objet)).format, 0, 0, ' ', |
'F', &longueur_effective, &recursivite)) == NULL) |
'F', &longueur_effective, &recursivite, d_vrai)) |
|
== NULL) |
{ |
{ |
liberation(s_etat_processus, s_objet_argument_3); |
liberation(s_etat_processus, s_objet_argument_3); |
liberation(s_etat_processus, s_objet_argument_2); |
liberation(s_etat_processus, s_objet_argument_2); |
Line 694 instruction_write(struct_processus *s_et
|
Line 712 instruction_write(struct_processus *s_et
|
|
|
free(chaine); |
free(chaine); |
|
|
if (alsprintf(&commande, "insert or replace into data " |
if (alsprintf(s_etat_processus, &commande, |
|
"insert or replace into data " |
"(id, data) values (%lld, '%s')", (*((integer8 *) |
"(id, data) values (%lld, '%s')", (*((integer8 *) |
(*s_objet_argument_2).objet)), chaine_utf8) < 0) |
(*s_objet_argument_2).objet)), chaine_utf8) < 0) |
{ |
{ |
Line 706 instruction_write(struct_processus *s_et
|
Line 725 instruction_write(struct_processus *s_et
|
free(chaine_utf8); |
free(chaine_utf8); |
|
|
if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite, |
if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite, |
commande, strlen(commande), &ppStmt, &queue) |
commande, (int) strlen(commande), &ppStmt, &queue) |
!= SQLITE_OK) |
!= SQLITE_OK) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
Line 744 instruction_write(struct_processus *s_et
|
Line 763 instruction_write(struct_processus *s_et
|
|
|
// Récupération de la position de la clef |
// Récupération de la position de la clef |
|
|
if (alsprintf(&commande, "select key from control " |
if (alsprintf(s_etat_processus, &commande, |
"where id = 1") < 0) |
"select key from control where id = 1") < 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
d_es_allocation_memoire; |
d_es_allocation_memoire; |
Line 753 instruction_write(struct_processus *s_et
|
Line 772 instruction_write(struct_processus *s_et
|
} |
} |
|
|
if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite, |
if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite, |
commande, strlen(commande), &ppStmt, &queue) |
commande, (int) strlen(commande), &ppStmt, &queue) |
!= SQLITE_OK) |
!= SQLITE_OK) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
return; |
return; |
} |
} |
|
|
if (sqlite3_step(ppStmt) != SQLITE_ROW) |
attente.tv_sec = 0; |
|
attente.tv_nsec = GRANULARITE_us * 1000; |
|
|
|
do |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
sqlite_status = sqlite3_step(ppStmt); |
return; |
|
} |
if (sqlite_status == SQLITE_ROW) |
|
{ |
|
break; |
|
} |
|
else if ((sqlite_status == SQLITE_BUSY) || |
|
(sqlite_status == SQLITE_LOCKED)) |
|
{ |
|
nanosleep(&attente, NULL); |
|
INCR_GRANULARITE(attente.tv_nsec); |
|
} |
|
else |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_erreur_fichier; |
|
return; |
|
} |
|
} while(sqlite_status != SQLITE_ROW); |
|
|
if (sqlite3_column_type(ppStmt, 0) != SQLITE_INTEGER) |
if (sqlite3_column_type(ppStmt, 0) != SQLITE_INTEGER) |
{ |
{ |
Line 875 instruction_write(struct_processus *s_et
|
Line 913 instruction_write(struct_processus *s_et
|
|
|
if ((chaine = formateur_fichier(s_etat_processus, |
if ((chaine = formateur_fichier(s_etat_processus, |
s_element, s_format, 0, 0, ' ', |
s_element, s_format, 0, 0, ' ', |
'F', &longueur_effective, &recursivite)) == NULL) |
'F', &longueur_effective, &recursivite, d_vrai)) |
|
== NULL) |
{ |
{ |
liberation(s_etat_processus, s_element); |
liberation(s_etat_processus, s_element); |
liberation(s_etat_processus, s_format); |
liberation(s_etat_processus, s_format); |
Line 901 instruction_write(struct_processus *s_et
|
Line 940 instruction_write(struct_processus *s_et
|
|
|
// Récupération de l'identifiant de la clef |
// Récupération de l'identifiant de la clef |
|
|
if (alsprintf(&commande, "select id from key where key = " |
if (alsprintf(s_etat_processus, &commande, |
"'%s'", clef_utf8) < 0) |
"select id from key where key = '%s'", clef_utf8) < 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
d_es_allocation_memoire; |
d_es_allocation_memoire; |
Line 910 instruction_write(struct_processus *s_et
|
Line 949 instruction_write(struct_processus *s_et
|
} |
} |
|
|
if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite, |
if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite, |
commande, strlen(commande), &ppStmt, &queue) |
commande, (int) strlen(commande), &ppStmt, &queue) |
!= SQLITE_OK) |
!= SQLITE_OK) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
return; |
return; |
} |
} |
|
|
switch(sqlite3_step(ppStmt)) |
attente.tv_sec = 0; |
|
attente.tv_nsec = GRANULARITE_us * 1000; |
|
|
|
do |
{ |
{ |
case SQLITE_ROW: |
switch(sqlite_status = sqlite3_step(ppStmt)) |
{ |
{ |
// Une clef existe. |
case SQLITE_ROW: |
|
{ |
|
// Une clef existe. |
|
|
mise_a_jour = d_vrai; |
mise_a_jour = d_vrai; |
break; |
break; |
} |
} |
|
|
case SQLITE_DONE: |
case SQLITE_DONE: |
{ |
{ |
// Aucune clef n'existe. |
// Aucune clef n'existe. |
|
|
mise_a_jour = d_faux; |
mise_a_jour = d_faux; |
|
|
if (sqlite3_finalize(ppStmt) != SQLITE_OK) |
if (sqlite3_finalize(ppStmt) != SQLITE_OK) |
{ |
{ |
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
d_es_erreur_fichier; |
d_es_erreur_fichier; |
return; |
return; |
} |
} |
|
|
free(commande); |
free(commande); |
|
|
if (alsprintf(&commande, "insert into key " |
if (alsprintf(s_etat_processus, &commande, |
"(key) values ('%s')", clef_utf8) < 0) |
"insert into key (key) values ('%s')", |
{ |
clef_utf8) < 0) |
(*s_etat_processus).erreur_systeme = |
{ |
d_es_allocation_memoire; |
(*s_etat_processus).erreur_systeme = |
return; |
d_es_allocation_memoire; |
} |
return; |
|
} |
|
|
if (sqlite3_prepare_v2((*descripteur) |
if (sqlite3_prepare_v2((*descripteur) |
.descripteur_sqlite, |
.descripteur_sqlite, commande, |
commande, strlen(commande), &ppStmt, &queue) |
(int) strlen(commande), &ppStmt, &queue) |
!= SQLITE_OK) |
!= SQLITE_OK) |
{ |
{ |
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
d_es_erreur_fichier; |
d_es_erreur_fichier; |
return; |
return; |
} |
} |
|
|
if (sqlite3_step(ppStmt) != SQLITE_DONE) |
if (sqlite3_step(ppStmt) != SQLITE_DONE) |
{ |
{ |
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
d_es_erreur_fichier; |
d_es_erreur_fichier; |
return; |
return; |
} |
} |
|
|
if (sqlite3_finalize(ppStmt) != SQLITE_OK) |
if (sqlite3_finalize(ppStmt) != SQLITE_OK) |
{ |
{ |
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
d_es_erreur_fichier; |
d_es_erreur_fichier; |
return; |
return; |
} |
} |
|
|
free(commande); |
free(commande); |
|
|
if (alsprintf(&commande, "select id from key " |
if (alsprintf(s_etat_processus, &commande, |
"where key = '%s'", clef_utf8) < 0) |
"select id from key where key = '%s'", |
{ |
clef_utf8) < 0) |
(*s_etat_processus).erreur_systeme = |
{ |
d_es_allocation_memoire; |
(*s_etat_processus).erreur_systeme = |
return; |
d_es_allocation_memoire; |
|
return; |
|
} |
|
|
|
if (sqlite3_prepare_v2((*descripteur) |
|
.descripteur_sqlite, commande, |
|
(int) strlen(commande), &ppStmt, &queue) |
|
!= SQLITE_OK) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_erreur_fichier; |
|
return; |
|
} |
|
|
|
break; |
} |
} |
|
|
if (sqlite3_prepare_v2((*descripteur) |
case SQLITE_BUSY: |
.descripteur_sqlite, |
case SQLITE_LOCKED: |
commande, strlen(commande), &ppStmt, &queue) |
|
!= SQLITE_OK) |
|
{ |
{ |
(*s_etat_processus).erreur_systeme = |
nanosleep(&attente, NULL); |
d_es_erreur_fichier; |
INCR_GRANULARITE(attente.tv_nsec); |
return; |
break; |
} |
} |
|
|
if (sqlite3_step(ppStmt) != SQLITE_ROW) |
default: |
{ |
{ |
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
d_es_erreur_fichier; |
d_es_erreur_fichier; |
return; |
return; |
} |
} |
|
|
break; |
|
} |
|
|
|
default: |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_erreur_fichier; |
|
return; |
|
} |
} |
} |
} while(sqlite_status != SQLITE_ROW); |
|
|
if (sqlite3_column_type(ppStmt, 0) != SQLITE_INTEGER) |
if (sqlite3_column_type(ppStmt, 0) != SQLITE_INTEGER) |
{ |
{ |
Line 1038 instruction_write(struct_processus *s_et
|
Line 1086 instruction_write(struct_processus *s_et
|
|
|
if (mise_a_jour == d_vrai) |
if (mise_a_jour == d_vrai) |
{ |
{ |
if (alsprintf(&commande, "update key set key = '%s' where " |
if (alsprintf(s_etat_processus, &commande, |
"id = %lld", clef_utf8, id) < 0) |
"update key set key = '%s' where id = %lld", |
|
clef_utf8, id) < 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
d_es_allocation_memoire; |
d_es_allocation_memoire; |
Line 1047 instruction_write(struct_processus *s_et
|
Line 1096 instruction_write(struct_processus *s_et
|
} |
} |
|
|
if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite, |
if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite, |
commande, strlen(commande), &ppStmt, &queue) |
commande, (int) strlen(commande), &ppStmt, &queue) |
!= SQLITE_OK) |
!= SQLITE_OK) |
{ |
{ |
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
Line 1074 instruction_write(struct_processus *s_et
|
Line 1123 instruction_write(struct_processus *s_et
|
|
|
// Effacement de l'enregistrement existant |
// Effacement de l'enregistrement existant |
|
|
if (alsprintf(&commande, "delete from data where " |
if (alsprintf(s_etat_processus, &commande, |
"key_id = %lld", id) < 0) |
"delete from data where key_id = %lld", id) < 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
d_es_allocation_memoire; |
d_es_allocation_memoire; |
Line 1083 instruction_write(struct_processus *s_et
|
Line 1132 instruction_write(struct_processus *s_et
|
} |
} |
|
|
if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite, |
if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite, |
commande, strlen(commande), &ppStmt, &queue) |
commande, (int) strlen(commande), &ppStmt, &queue) |
!= SQLITE_OK) |
!= SQLITE_OK) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
Line 1182 instruction_write(struct_processus *s_et
|
Line 1231 instruction_write(struct_processus *s_et
|
|
|
if ((chaine = formateur_fichier(s_etat_processus, |
if ((chaine = formateur_fichier(s_etat_processus, |
s_element, s_format, 0, 0, ' ', |
s_element, s_format, 0, 0, ' ', |
'F', &longueur_effective, &recursivite)) == NULL) |
'F', &longueur_effective, &recursivite, d_vrai)) |
|
== NULL) |
{ |
{ |
free(clef_utf8); |
free(clef_utf8); |
|
|
Line 1208 instruction_write(struct_processus *s_et
|
Line 1258 instruction_write(struct_processus *s_et
|
|
|
free(chaine); |
free(chaine); |
|
|
if (alsprintf(&commande, "insert into data " |
if (alsprintf(s_etat_processus, &commande, |
"(data, key_id, sequence) values " |
"insert into data (data, key_id, sequence) values " |
"('%s', %lld, %lld)", chaine_utf8, id, ordre) < 0) |
"('%s', %lld, %lld)", chaine_utf8, id, ordre) < 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
Line 1218 instruction_write(struct_processus *s_et
|
Line 1268 instruction_write(struct_processus *s_et
|
} |
} |
|
|
if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite, |
if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite, |
commande, strlen(commande), &ppStmt, &queue) |
commande, (int) strlen(commande), &ppStmt, &queue) |
!= SQLITE_OK) |
!= SQLITE_OK) |
{ |
{ |
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
Line 1275 instruction_write(struct_processus *s_et
|
Line 1325 instruction_write(struct_processus *s_et
|
* Fichiers non formatés |
* Fichiers non formatés |
*/ |
*/ |
|
|
if ((chaine = formateur_fichier(s_etat_processus, |
|
s_objet_argument_2, (*((struct_fichier *) |
|
(*s_objet_argument_1).objet)).format, 0, 0, ' ', 'U', |
|
&longueur_effective, &recursivite)) == NULL) |
|
{ |
|
liberation(s_etat_processus, s_objet_argument_2); |
|
liberation(s_etat_processus, s_objet_argument_1); |
|
|
|
return; |
|
} |
|
|
|
if ((*((struct_fichier *) (*s_objet_argument_1).objet)).acces |
if ((*((struct_fichier *) (*s_objet_argument_1).objet)).acces |
== 'S') |
== 'S') |
{ |
{ |
|
if ((*s_objet_argument_2).type != LST) |
|
{ |
|
liberation(s_etat_processus, s_objet_argument_2); |
|
liberation(s_etat_processus, s_objet_argument_1); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_type_argument; |
|
return; |
|
} |
|
|
|
if ((chaine = formateur_fichier(s_etat_processus, |
|
s_objet_argument_2, (*((struct_fichier *) |
|
(*s_objet_argument_1).objet)).format, 0, 0, ' ', 'U', |
|
&longueur_effective, &recursivite, d_vrai)) == NULL) |
|
{ |
|
liberation(s_etat_processus, s_objet_argument_2); |
|
liberation(s_etat_processus, s_objet_argument_1); |
|
|
|
return; |
|
} |
|
|
BUG(((*descripteur).type != 'C'), uprintf("Bad filetype !\n")); |
BUG(((*descripteur).type != 'C'), uprintf("Bad filetype !\n")); |
|
|
if (fseek((*descripteur).descripteur_c, (long) 0, SEEK_END) |
if (fseek((*descripteur).descripteur_c, (long) 0, SEEK_END) |
Line 1301 instruction_write(struct_processus *s_et
|
Line 1361 instruction_write(struct_processus *s_et
|
return; |
return; |
} |
} |
|
|
if (fwrite(chaine, sizeof(unsigned char), longueur_effective, |
if (write(fileno((*descripteur).descripteur_c), |
(*descripteur).descripteur_c) != |
chaine, (size_t) longueur_effective) != |
(size_t) longueur_effective) |
(ssize_t) longueur_effective) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
return; |
return; |
Line 1312 instruction_write(struct_processus *s_et
|
Line 1372 instruction_write(struct_processus *s_et
|
else if ((*((struct_fichier *) (*s_objet_argument_1).objet)).acces |
else if ((*((struct_fichier *) (*s_objet_argument_1).objet)).acces |
== 'D') |
== 'D') |
{ |
{ |
|
if ((*s_objet_argument_2).type != INT) |
|
{ |
|
liberation(s_etat_processus, s_objet_argument_2); |
|
liberation(s_etat_processus, s_objet_argument_1); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_type_argument; |
|
return; |
|
} |
|
|
|
if (depilement(s_etat_processus, &((*s_etat_processus) |
|
.l_base_pile), &s_objet_argument_3) == d_erreur) |
|
{ |
|
(*s_etat_processus).erreur_execution = d_ex_manque_argument; |
|
return; |
|
} |
|
|
|
if ((*s_objet_argument_3).type != LST) |
|
{ |
|
liberation(s_etat_processus, s_objet_argument_3); |
|
liberation(s_etat_processus, s_objet_argument_2); |
|
liberation(s_etat_processus, s_objet_argument_1); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_type_argument; |
|
return; |
|
} |
|
|
|
if ((chaine = formateur_fichier(s_etat_processus, |
|
s_objet_argument_2, (*((struct_fichier *) |
|
(*s_objet_argument_1).objet)).format, 0, 0, ' ', 'U', |
|
&longueur_effective, &recursivite, d_faux)) == NULL) |
|
{ |
|
liberation(s_etat_processus, s_objet_argument_2); |
|
liberation(s_etat_processus, s_objet_argument_1); |
|
|
|
return; |
|
} |
} |
} |
else |
else // Fichiers indexés |
{ |
{ |
/* Fichiers indexés : panique totale ! */ |
if ((*s_objet_argument_2).type != LST) |
|
{ |
|
liberation(s_etat_processus, s_objet_argument_2); |
|
liberation(s_etat_processus, s_objet_argument_1); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_type_argument; |
|
return; |
|
} |
|
|
|
if ((chaine = formateur_fichier(s_etat_processus, |
|
s_objet_argument_2, (*((struct_fichier *) |
|
(*s_objet_argument_1).objet)).format, 0, 0, ' ', 'U', |
|
&longueur_effective, &recursivite, d_faux)) == NULL) |
|
{ |
|
liberation(s_etat_processus, s_objet_argument_2); |
|
liberation(s_etat_processus, s_objet_argument_1); |
|
|
|
return; |
|
} |
} |
} |
|
|
free(chaine); |
free(chaine); |
Line 1380 instruction_write(struct_processus *s_et
|
Line 1497 instruction_write(struct_processus *s_et
|
return; |
return; |
} |
} |
|
|
if ((format_chaine = conversion_majuscule((unsigned char *) |
if ((format_chaine = conversion_majuscule(s_etat_processus, |
(*(*l_element_courant_format).donnee).objet)) |
(unsigned char *) (*(*l_element_courant_format) |
== NULL) |
.donnee).objet)) == NULL) |
{ |
{ |
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
d_es_allocation_memoire; |
d_es_allocation_memoire; |
return; |
return; |
} |
} |
|
|
if (strncmp("LENGTH*(", format_chaine, 8) != 0) |
if (strcmp("LINE*(*)", format_chaine) == 0) |
{ |
{ |
free(format_chaine); |
format_oriente_ligne = d_vrai; |
|
format_degenere = d_vrai; |
liberation(s_etat_processus, s_objet_argument_2); |
|
liberation(s_etat_processus, s_objet_argument_1); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_format_fichier; |
|
return; |
|
} |
} |
|
else |
longueur = strlen(format_chaine); |
|
|
|
if (format_chaine[longueur - 1] != ')') |
|
{ |
{ |
free(format_chaine); |
format_oriente_ligne = d_faux; |
|
|
liberation(s_etat_processus, s_objet_argument_2); |
if (strncmp("LENGTH*(", format_chaine, 8) != 0) |
liberation(s_etat_processus, s_objet_argument_1); |
{ |
|
free(format_chaine); |
|
|
(*s_etat_processus).erreur_execution = |
liberation(s_etat_processus, s_objet_argument_2); |
d_ex_erreur_format_fichier; |
liberation(s_etat_processus, s_objet_argument_1); |
return; |
|
} |
|
|
|
format_chaine[longueur] = d_code_fin_chaine; |
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_format_fichier; |
|
return; |
|
} |
|
|
if (format_chaine[8] == '*') |
longueur = (integer8) strlen(format_chaine); |
{ |
|
format_degenere = d_vrai; |
|
} |
|
else |
|
{ |
|
// Détermination de la longueur |
|
format_degenere = d_faux; |
|
|
|
if (sscanf(&(format_chaine[8]), "%ld", &longueur) != 1) |
if (format_chaine[longueur - 1] != ')') |
{ |
{ |
free(format_chaine); |
free(format_chaine); |
|
|
Line 1437 instruction_write(struct_processus *s_et
|
Line 1540 instruction_write(struct_processus *s_et
|
d_ex_erreur_format_fichier; |
d_ex_erreur_format_fichier; |
return; |
return; |
} |
} |
|
|
|
format_chaine[longueur] = d_code_fin_chaine; |
|
|
|
if (format_chaine[8] == '*') |
|
{ |
|
format_degenere = d_vrai; |
|
} |
|
else |
|
{ |
|
// Détermination de la longueur |
|
format_degenere = d_faux; |
|
|
|
if (sscanf(&(format_chaine[8]), "%lld", &longueur) |
|
!= 1) |
|
{ |
|
free(format_chaine); |
|
|
|
liberation(s_etat_processus, |
|
s_objet_argument_2); |
|
liberation(s_etat_processus, |
|
s_objet_argument_1); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_format_fichier; |
|
return; |
|
} |
|
} |
} |
} |
|
|
free(format_chaine); |
free(format_chaine); |
Line 1453 instruction_write(struct_processus *s_et
|
Line 1583 instruction_write(struct_processus *s_et
|
if ((format_degenere == d_vrai) || |
if ((format_degenere == d_vrai) || |
(longueur_effective < longueur)) |
(longueur_effective < longueur)) |
{ |
{ |
if (fwrite(chaine, sizeof(unsigned char), |
if (write(fileno((*descripteur).descripteur_c), |
longueur_effective, |
chaine, (size_t) longueur_effective) |
(*descripteur).descripteur_c) != |
!= (ssize_t) longueur_effective) |
(size_t) longueur_effective) |
|
{ |
{ |
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
d_es_erreur_fichier; |
d_es_erreur_fichier; |
Line 1465 instruction_write(struct_processus *s_et
|
Line 1594 instruction_write(struct_processus *s_et
|
} |
} |
else |
else |
{ |
{ |
if (fwrite(chaine, sizeof(unsigned char), |
if (write(fileno((*descripteur).descripteur_c), |
longueur_effective, |
chaine, (size_t) longueur_effective) |
(*descripteur).descripteur_c) != |
!= (ssize_t) longueur) |
(size_t) longueur) |
|
{ |
{ |
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
d_es_erreur_fichier; |
d_es_erreur_fichier; |
Line 1478 instruction_write(struct_processus *s_et
|
Line 1606 instruction_write(struct_processus *s_et
|
|
|
free(chaine); |
free(chaine); |
|
|
|
if (format_oriente_ligne == d_vrai) |
|
{ |
|
if (write(fileno((*descripteur).descripteur_c), |
|
"\n", 1) != 1) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_erreur_fichier; |
|
return; |
|
} |
|
} |
|
|
l_element_courant = (*l_element_courant).suivant; |
l_element_courant = (*l_element_courant).suivant; |
l_element_courant_format = (*l_element_courant_format) |
l_element_courant_format = (*l_element_courant_format) |
.suivant; |
.suivant; |
Line 1531 instruction_write(struct_processus *s_et
|
Line 1670 instruction_write(struct_processus *s_et
|
if ((chaine = formateur_fichier(s_etat_processus, |
if ((chaine = formateur_fichier(s_etat_processus, |
s_objet_argument_2, (*((struct_socket *) |
s_objet_argument_2, (*((struct_socket *) |
(*s_objet_argument_1).objet)).format, 0, 0, ' ', 'F', |
(*s_objet_argument_1).objet)).format, 0, 0, ' ', 'F', |
&longueur_effective, &recursivite)) == NULL) |
&longueur_effective, &recursivite, d_faux)) == NULL) |
{ |
{ |
liberation(s_etat_processus, s_objet_argument_2); |
liberation(s_etat_processus, s_objet_argument_2); |
liberation(s_etat_processus, s_objet_argument_1); |
liberation(s_etat_processus, s_objet_argument_1); |
Line 1546 instruction_write(struct_processus *s_et
|
Line 1685 instruction_write(struct_processus *s_et
|
* Sockets non formatées |
* Sockets non formatées |
*/ |
*/ |
|
|
chaine = NULL; |
if ((chaine = formateur_fichier(s_etat_processus, |
|
s_objet_argument_2, (*((struct_socket *) |
|
(*s_objet_argument_1).objet)).format, 0, 0, ' ', 'U', |
|
&longueur_effective, &recursivite, d_faux)) == NULL) |
|
{ |
|
liberation(s_etat_processus, s_objet_argument_2); |
|
liberation(s_etat_processus, s_objet_argument_1); |
|
|
|
return; |
|
} |
} |
} |
else |
else |
{ |
{ |
Line 1581 instruction_write(struct_processus *s_et
|
Line 1729 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, ®istre) != 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, ®istre, 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, ®istre) != 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, longueur_effective, 0) < 0) |
.socket, chaine, (size_t) longueur_effective, 0) < 0) |
{ |
{ |
ios = errno; |
ios = errno; |
|
|
if (sigaction(SIGPIPE, ®istre, NULL) != 0) |
if (sigaction(SIGPIPE, ®istre, 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 1642 instruction_write(struct_processus *s_et
|
Line 1797 instruction_write(struct_processus *s_et
|
return; |
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 |
# ifndef SEMAPHORES_NOMMES |
while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0) |
while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0) |
# else |
# else |
Line 1660 instruction_write(struct_processus *s_et
|
Line 1850 instruction_write(struct_processus *s_et
|
return; |
return; |
} |
} |
} |
} |
|
|
if (sigaction(SIGPIPE, ®istre, NULL) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_signal; |
|
return; |
|
} |
|
} |
} |
else |
else |
{ // Sockets non connectées |
{ // Sockets non connectées |
Line 1711 instruction_write(struct_processus *s_et
|
Line 1895 instruction_write(struct_processus *s_et
|
|
|
if (sendto((*((struct_socket *) |
if (sendto((*((struct_socket *) |
(*s_objet_argument_1).objet)).socket, chaine, |
(*s_objet_argument_1).objet)).socket, chaine, |
longueur_effective, 0, (struct sockaddr *) |
(size_t) longueur_effective, 0, (struct sockaddr *) |
&adresse_unix, sizeof(adresse_unix)) < 0) |
&adresse_unix, sizeof(adresse_unix)) < 0) |
{ |
{ |
ios = errno; |
ios = errno; |
Line 1737 instruction_write(struct_processus *s_et
|
Line 1921 instruction_write(struct_processus *s_et
|
return; |
return; |
} |
} |
|
|
|
if (ios == EMSGSIZE) |
|
{ |
|
(*s_etat_processus).erreur_execution = |
|
d_ex_taille_message; |
|
return; |
|
} |
|
|
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
return; |
return; |
Line 1766 instruction_write(struct_processus *s_et
|
Line 1956 instruction_write(struct_processus *s_et
|
{ // Adresse IPv4 |
{ // Adresse IPv4 |
calcul_adresse = 0; |
calcul_adresse = 0; |
for(i = 0; i < 4; calcul_adresse = |
for(i = 0; i < 4; calcul_adresse = |
(256 * calcul_adresse) + adresse[i++]); |
(256 * calcul_adresse) + |
|
((unsigned char) adresse[i++])); |
|
|
memset(&adresse_ipv4, 0, sizeof(adresse_ipv4)); |
memset(&adresse_ipv4, 0, sizeof(adresse_ipv4)); |
adresse_ipv4.sin_family = AF_INET; |
adresse_ipv4.sin_family = AF_INET; |
adresse_ipv4.sin_port = htons(port); |
adresse_ipv4.sin_port = htons((uint16_t) port); |
adresse_ipv4.sin_addr.s_addr = htonl(calcul_adresse); |
adresse_ipv4.sin_addr.s_addr = htonl(calcul_adresse); |
|
|
# ifndef SEMAPHORES_NOMMES |
# ifndef SEMAPHORES_NOMMES |
Line 1786 instruction_write(struct_processus *s_et
|
Line 1977 instruction_write(struct_processus *s_et
|
|
|
if (sendto((*((struct_socket *) |
if (sendto((*((struct_socket *) |
(*s_objet_argument_1).objet)).socket, chaine, |
(*s_objet_argument_1).objet)).socket, chaine, |
longueur_effective, 0, (struct sockaddr *) |
(size_t) longueur_effective, 0, (struct sockaddr *) |
&adresse_ipv4, sizeof(adresse_ipv4)) < 0) |
&adresse_ipv4, sizeof(adresse_ipv4)) < 0) |
{ |
{ |
|
ios = errno; |
|
|
# ifndef SEMAPHORES_NOMMES |
# ifndef SEMAPHORES_NOMMES |
while(sem_wait(&((*s_etat_processus) |
while(sem_wait(&((*s_etat_processus) |
.semaphore_fork)) != 0) |
.semaphore_fork)) != 0) |
Line 1805 instruction_write(struct_processus *s_et
|
Line 1998 instruction_write(struct_processus *s_et
|
} |
} |
} |
} |
|
|
|
if ((ios == EPIPE) || (ios == ECONNRESET)) |
|
{ |
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_acces_fichier; |
|
return; |
|
} |
|
|
|
if (ios == EMSGSIZE) |
|
{ |
|
(*s_etat_processus).erreur_execution = |
|
d_ex_taille_message; |
|
return; |
|
} |
|
|
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
d_es_erreur_fichier; |
d_es_erreur_fichier; |
return; |
return; |
Line 1854 instruction_write(struct_processus *s_et
|
Line 2061 instruction_write(struct_processus *s_et
|
|
|
for(i = 0; i < 16; |
for(i = 0; i < 16; |
adresse_ipv6.sin6_addr.s6_addr[i] = |
adresse_ipv6.sin6_addr.s6_addr[i] = |
adresse[i], i++); |
(unsigned char) adresse[i], i++); |
|
|
# ifndef SEMAPHORES_NOMMES |
# ifndef SEMAPHORES_NOMMES |
if (sem_post(&((*s_etat_processus).semaphore_fork)) |
if (sem_post(&((*s_etat_processus).semaphore_fork)) |
Line 1869 instruction_write(struct_processus *s_et
|
Line 2076 instruction_write(struct_processus *s_et
|
|
|
if (sendto((*((struct_socket *) |
if (sendto((*((struct_socket *) |
(*s_objet_argument_1).objet)).socket, chaine, |
(*s_objet_argument_1).objet)).socket, chaine, |
longueur_effective, 0, (struct sockaddr *) |
(size_t) longueur_effective, 0, (struct sockaddr *) |
&adresse_ipv6, sizeof(adresse_ipv6)) < 0) |
&adresse_ipv6, sizeof(adresse_ipv6)) < 0) |
{ |
{ |
|
ios = errno; |
|
|
# ifndef SEMAPHORES_NOMMES |
# ifndef SEMAPHORES_NOMMES |
while(sem_wait(&((*s_etat_processus) |
while(sem_wait(&((*s_etat_processus) |
.semaphore_fork)) != 0) |
.semaphore_fork)) != 0) |
Line 1888 instruction_write(struct_processus *s_et
|
Line 2097 instruction_write(struct_processus *s_et
|
} |
} |
} |
} |
|
|
|
if ((ios == EPIPE) || (ios == ECONNRESET)) |
|
{ |
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_acces_fichier; |
|
return; |
|
} |
|
|
|
if (ios == EMSGSIZE) |
|
{ |
|
(*s_etat_processus).erreur_execution = |
|
d_ex_taille_message; |
|
return; |
|
} |
|
|
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
d_es_erreur_fichier; |
d_es_erreur_fichier; |
return; |
return; |
Line 2049 instruction_wflock(struct_processus *s_e
|
Line 2272 instruction_wflock(struct_processus *s_e
|
|
|
do |
do |
{ |
{ |
if ((chaine = conversion_majuscule((unsigned char *) |
if ((chaine = conversion_majuscule(s_etat_processus, |
(*s_objet_argument_1).objet)) == NULL) |
(unsigned char *) (*s_objet_argument_1).objet)) == NULL) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
return; |
return; |
Line 2102 instruction_wflock(struct_processus *s_e
|
Line 2325 instruction_wflock(struct_processus *s_e
|
return; |
return; |
} |
} |
|
|
# ifndef SEMAPHORES_NOMMES |
if (lock.l_type == F_UNLCK) |
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; |
drapeau = d_vrai; |
return; |
|
} |
} |
|
else |
# 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 (pthread_mutex_lock(&(*s_etat_processus).mutex_interruptions) |
|
!= 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
} |
} |
} |
|
|
|
if (lock.l_type == F_UNLCK) |
|
{ |
|
drapeau = d_vrai; |
|
} |
|
else |
|
{ |
|
if ((*s_etat_processus).nombre_interruptions_non_affectees != 0) |
if ((*s_etat_processus).nombre_interruptions_non_affectees != 0) |
{ |
{ |
affectation_interruptions_logicielles(s_etat_processus); |
affectation_interruptions_logicielles(s_etat_processus); |
} |
} |
|
|
if ((*s_etat_processus).nombre_interruptions_en_queue |
if (pthread_mutex_unlock(&(*s_etat_processus) |
!= 0) |
.mutex_interruptions) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
|
|
if ((*s_etat_processus).nombre_interruptions_en_queue != 0) |
{ |
{ |
registre_instruction_valide = |
registre_instruction_valide = |
(*s_etat_processus).instruction_valide; |
(*s_etat_processus).instruction_valide; |
Line 2147 instruction_wflock(struct_processus *s_e
|
Line 2360 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 2251 instruction_wfproc(struct_processus *s_e
|
Line 2488 instruction_wfproc(struct_processus *s_e
|
} |
} |
} |
} |
|
|
if (pthread_mutex_lock(&((*s_etat_processus).mutex)) != 0) |
if (pthread_mutex_lock(&((*s_etat_processus).mutex_pile_processus)) |
|
!= 0) |
{ |
{ |
if ((*s_etat_processus).profilage == d_vrai) |
if ((*s_etat_processus).profilage == d_vrai) |
{ |
{ |
Line 2316 instruction_wfproc(struct_processus *s_e
|
Line 2554 instruction_wfproc(struct_processus *s_e
|
profilage(s_etat_processus, NULL); |
profilage(s_etat_processus, NULL); |
} |
} |
|
|
if (pthread_mutex_unlock(&((*s_etat_processus).mutex)) != 0) |
if (pthread_mutex_unlock(&((*s_etat_processus) |
|
.mutex_pile_processus)) != 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
Line 2341 instruction_wfproc(struct_processus *s_e
|
Line 2580 instruction_wfproc(struct_processus *s_e
|
{ |
{ |
if (envoi_signal_processus((*(*((struct_processus_fils *) |
if (envoi_signal_processus((*(*((struct_processus_fils *) |
(*(*l_element_courant).donnee).objet)).thread).pid, |
(*(*l_element_courant).donnee).objet)).thread).pid, |
rpl_signull) != 0) |
rpl_signull, d_faux) != 0) |
{ |
{ |
drapeau_fin = d_vrai; |
drapeau_fin = d_vrai; |
} |
} |
Line 2396 instruction_wfproc(struct_processus *s_e
|
Line 2635 instruction_wfproc(struct_processus *s_e
|
* Le processus n'est pas terminé |
* Le processus n'est pas terminé |
*/ |
*/ |
|
|
if (pthread_mutex_unlock(&((*s_etat_processus).mutex)) != 0) |
if (pthread_mutex_lock(&((*s_etat_processus) |
|
.mutex_interruptions)) != 0) |
{ |
{ |
|
pthread_mutex_unlock(&((*s_etat_processus) |
|
.mutex_pile_processus)); |
|
|
if ((*s_etat_processus).profilage == d_vrai) |
if ((*s_etat_processus).profilage == d_vrai) |
{ |
{ |
profilage(s_etat_processus, NULL); |
profilage(s_etat_processus, NULL); |
Line 2414 instruction_wfproc(struct_processus *s_e
|
Line 2657 instruction_wfproc(struct_processus *s_e
|
affectation_interruptions_logicielles(s_etat_processus); |
affectation_interruptions_logicielles(s_etat_processus); |
} |
} |
|
|
if ((*s_etat_processus).nombre_interruptions_en_queue |
if (pthread_mutex_unlock(&((*s_etat_processus) |
!= 0) |
.mutex_interruptions)) != 0) |
|
{ |
|
pthread_mutex_unlock(&((*s_etat_processus) |
|
.mutex_pile_processus)); |
|
|
|
if ((*s_etat_processus).profilage == d_vrai) |
|
{ |
|
profilage(s_etat_processus, NULL); |
|
} |
|
|
|
(*s_etat_processus).erreur_systeme = |
|
d_es_processus; |
|
return; |
|
} |
|
|
|
if (pthread_mutex_unlock(&((*s_etat_processus) |
|
.mutex_pile_processus)) != 0) |
|
{ |
|
if ((*s_etat_processus).profilage == d_vrai) |
|
{ |
|
profilage(s_etat_processus, NULL); |
|
} |
|
|
|
(*s_etat_processus).erreur_systeme = |
|
d_es_processus; |
|
return; |
|
} |
|
|
|
if ((*s_etat_processus).nombre_interruptions_en_queue != 0) |
{ |
{ |
registre_instruction_valide = |
registre_instruction_valide = |
(*s_etat_processus).instruction_valide; |
(*s_etat_processus).instruction_valide; |
Line 2454 instruction_wfproc(struct_processus *s_e
|
Line 2725 instruction_wfproc(struct_processus *s_e
|
|
|
scrutation_injection(s_etat_processus); |
scrutation_injection(s_etat_processus); |
|
|
if (pthread_mutex_lock(&((*s_etat_processus).mutex)) != 0) |
if (pthread_mutex_lock(&((*s_etat_processus) |
|
.mutex_pile_processus)) != 0) |
{ |
{ |
if ((*s_etat_processus).profilage == d_vrai) |
if ((*s_etat_processus).profilage == d_vrai) |
{ |
{ |
Line 2476 instruction_wfproc(struct_processus *s_e
|
Line 2748 instruction_wfproc(struct_processus *s_e
|
profilage(s_etat_processus, NULL); |
profilage(s_etat_processus, NULL); |
} |
} |
|
|
if (pthread_mutex_unlock(&((*s_etat_processus).mutex)) != 0) |
if (pthread_mutex_unlock(&((*s_etat_processus).mutex_pile_processus)) |
|
!= 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
Line 2579 instruction_wfdata(struct_processus *s_e
|
Line 2852 instruction_wfdata(struct_processus *s_e
|
} |
} |
} |
} |
|
|
if (pthread_mutex_lock(&((*s_etat_processus).mutex)) != 0) |
if (pthread_mutex_lock(&((*s_etat_processus).mutex_pile_processus)) |
|
!= 0) |
{ |
{ |
if ((*s_etat_processus).profilage == d_vrai) |
if ((*s_etat_processus).profilage == d_vrai) |
{ |
{ |
Line 2639 instruction_wfdata(struct_processus *s_e
|
Line 2913 instruction_wfdata(struct_processus *s_e
|
profilage(s_etat_processus, NULL); |
profilage(s_etat_processus, NULL); |
} |
} |
|
|
if (pthread_mutex_unlock(&((*s_etat_processus).mutex)) != 0) |
if (pthread_mutex_unlock(&((*s_etat_processus) |
|
.mutex_pile_processus)) != 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
Line 2682 instruction_wfdata(struct_processus *s_e
|
Line 2957 instruction_wfdata(struct_processus *s_e
|
return; |
return; |
} |
} |
|
|
if (pthread_mutex_unlock(&((*s_etat_processus).mutex)) != 0) |
if (pthread_mutex_unlock(&((*s_etat_processus) |
|
.mutex_pile_processus)) != 0) |
{ |
{ |
if ((*s_etat_processus).profilage == d_vrai) |
if ((*s_etat_processus).profilage == d_vrai) |
{ |
{ |
Line 2723 instruction_wfdata(struct_processus *s_e
|
Line 2999 instruction_wfdata(struct_processus *s_e
|
|
|
scrutation_injection(s_etat_processus); |
scrutation_injection(s_etat_processus); |
|
|
|
if (pthread_mutex_lock(&(*s_etat_processus) |
|
.mutex_interruptions) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
|
if ((*s_etat_processus).nombre_interruptions_non_affectees |
if ((*s_etat_processus).nombre_interruptions_non_affectees |
!= 0) |
!= 0) |
{ |
{ |
affectation_interruptions_logicielles(s_etat_processus); |
affectation_interruptions_logicielles(s_etat_processus); |
} |
} |
|
|
|
if (pthread_mutex_unlock(&(*s_etat_processus) |
|
.mutex_interruptions) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
|
if ((*s_etat_processus).nombre_interruptions_en_queue != 0) |
if ((*s_etat_processus).nombre_interruptions_en_queue != 0) |
{ |
{ |
registre_instruction_valide = |
registre_instruction_valide = |
Line 2748 instruction_wfdata(struct_processus *s_e
|
Line 3038 instruction_wfdata(struct_processus *s_e
|
return; |
return; |
} |
} |
|
|
if (pthread_mutex_lock(&((*s_etat_processus).mutex)) != 0) |
if (pthread_mutex_lock(&((*s_etat_processus) |
|
.mutex_pile_processus)) != 0) |
{ |
{ |
if ((*s_etat_processus).profilage == d_vrai) |
if ((*s_etat_processus).profilage == d_vrai) |
{ |
{ |
Line 2775 instruction_wfdata(struct_processus *s_e
|
Line 3066 instruction_wfdata(struct_processus *s_e
|
profilage(s_etat_processus, NULL); |
profilage(s_etat_processus, NULL); |
} |
} |
|
|
if (pthread_mutex_unlock(&((*s_etat_processus).mutex)) != 0) |
if (pthread_mutex_unlock(&((*s_etat_processus).mutex_pile_processus)) |
|
!= 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
Line 2807 instruction_wfdata(struct_processus *s_e
|
Line 3099 instruction_wfdata(struct_processus *s_e
|
================================================================================ |
================================================================================ |
*/ |
*/ |
|
|
|
static inline logical1 |
|
options_sockets(struct_processus *s_etat_processus, struct_socket *s_socket) |
|
{ |
|
if (((*s_socket).options & (1 << d_BROADCAST)) != 0) |
|
{ |
|
if (setsockopt((*s_socket).socket, SOL_SOCKET, SO_BROADCAST, NULL, 0) |
|
!= 0) |
|
{ |
|
return(d_erreur); |
|
} |
|
} |
|
|
|
if (((*s_socket).options & (1 << d_DONT_ROUTE)) != 0) |
|
{ |
|
if (setsockopt((*s_socket).socket, SOL_SOCKET, SO_DONTROUTE, NULL, 0) |
|
!= 0) |
|
{ |
|
return(d_erreur); |
|
} |
|
} |
|
|
|
if (((*s_socket).options & (1 << d_KEEP_ALIVE)) != 0) |
|
{ |
|
if (setsockopt((*s_socket).socket, SOL_SOCKET, SO_KEEPALIVE, NULL, 0) |
|
!= 0) |
|
{ |
|
return(d_erreur); |
|
} |
|
} |
|
|
|
# ifdef SO_PRIORITY |
|
if (((*s_socket).options & (1 << d_PRIORITY)) != 0) |
|
{ |
|
if (setsockopt((*s_socket).socket, SOL_SOCKET, SO_PRIORITY, |
|
&((*s_socket).priorite), sizeof((*s_socket).priorite)) != 0) |
|
{ |
|
return(d_erreur); |
|
} |
|
} |
|
# endif |
|
|
|
// Les deux options suivantes ne peuvent être positionnées simultanément. |
|
|
|
if (((*s_socket).options & (1 << d_RECEIVE_BUFFER)) != 0) |
|
{ |
|
if (setsockopt((*s_socket).socket, SOL_SOCKET, SO_RCVBUF, |
|
&((*s_socket).buffer_reception), |
|
sizeof((*s_socket).buffer_reception)) != 0) |
|
{ |
|
return(d_erreur); |
|
} |
|
} |
|
|
|
# ifdef SO_RCVBUFFORCE |
|
if (((*s_socket).options & (1 << d_FORCE_RECEIVE_BUFFER)) != 0) |
|
{ |
|
if (setsockopt((*s_socket).socket, SOL_SOCKET, SO_RCVBUFFORCE, |
|
&((*s_socket).buffer_reception), |
|
sizeof((*s_socket).buffer_reception)) != 0) |
|
{ |
|
return(d_erreur); |
|
} |
|
} |
|
# endif |
|
|
|
// Même remarque |
|
|
|
if (((*s_socket).options & (1 << d_SEND_BUFFER)) != 0) |
|
{ |
|
if (setsockopt((*s_socket).socket, SOL_SOCKET, SO_SNDBUF, |
|
&((*s_socket).buffer_emission), |
|
sizeof((*s_socket).buffer_emission)) != 0) |
|
{ |
|
return(d_erreur); |
|
} |
|
} |
|
|
|
# ifdef SO_SNDBUFFORCE |
|
if (((*s_socket).options & (1 << d_FORCE_SEND_BUFFER)) != 0) |
|
{ |
|
if (setsockopt((*s_socket).socket, SOL_SOCKET, SO_SNDBUFFORCE, |
|
&((*s_socket).buffer_emission), |
|
sizeof((*s_socket).buffer_emission)) != 0) |
|
{ |
|
return(d_erreur); |
|
} |
|
} |
|
# endif |
|
|
|
if (((*s_socket).options & (1 << d_RECEIVING_TIMEOUT)) != 0) |
|
{ |
|
if (setsockopt((*s_socket).socket, SOL_SOCKET, SO_RCVTIMEO, |
|
&((*s_socket).timeout_emission), |
|
sizeof((*s_socket).timeout_emission)) != 0) |
|
{ |
|
return(d_erreur); |
|
} |
|
} |
|
|
|
if (((*s_socket).options & (1 << d_SENDING_TIMEOUT)) != 0) |
|
{ |
|
if (setsockopt((*s_socket).socket, SOL_SOCKET, SO_SNDTIMEO, |
|
&((*s_socket).timeout_emission), |
|
sizeof((*s_socket).timeout_emission)) != 0) |
|
{ |
|
return(d_erreur); |
|
} |
|
} |
|
|
|
return(d_absence_erreur);; |
|
} |
|
|
|
|
void |
void |
instruction_wfsock(struct_processus *s_etat_processus) |
instruction_wfsock(struct_processus *s_etat_processus) |
{ |
{ |
Line 2828 instruction_wfsock(struct_processus *s_e
|
Line 3233 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 2877 instruction_wfsock(struct_processus *s_e
|
Line 3280 instruction_wfsock(struct_processus *s_e
|
(*s_objet_argument).objet)).type, "SEQUENTIAL DATAGRAM") != 0)) |
(*s_objet_argument).objet)).type, "SEQUENTIAL DATAGRAM") != 0)) |
{ |
{ |
// Mode non connecté : l'attente se fait sur un poll() |
// Mode non connecté : l'attente se fait sur un poll() |
|
#define DEBUG_RETURN |
if ((s_objet_resultat = copie_objet(s_etat_processus, |
if ((s_objet_resultat = copie_objet(s_etat_processus, |
s_objet_argument, 'P')) == NULL) |
s_objet_argument, 'P')) == NULL) |
{ |
{ |
Line 2992 instruction_wfsock(struct_processus *s_e
|
Line 3395 instruction_wfsock(struct_processus *s_e
|
{ |
{ |
drapeau = d_vrai; |
drapeau = d_vrai; |
|
|
# ifndef SEMAPHORES_NOMMES |
# ifndef SEMAPHORES_NOMMES |
if (sem_post(&((*s_etat_processus).semaphore_fork)) |
if (sem_post(&((*s_etat_processus).semaphore_fork)) |
!= 0) |
!= 0) |
# else |
# else |
if (sem_post((*s_etat_processus).semaphore_fork) != 0) |
if (sem_post((*s_etat_processus).semaphore_fork) != 0) |
# endif |
# endif |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
Line 3012 instruction_wfsock(struct_processus *s_e
|
Line 3415 instruction_wfsock(struct_processus *s_e
|
erreur = errno; |
erreur = errno; |
|
|
# ifndef SEMAPHORES_NOMMES |
# ifndef SEMAPHORES_NOMMES |
while(sem_wait(&((*s_etat_processus) |
while(sem_wait(&((*s_etat_processus) |
.semaphore_fork)) != 0) |
.semaphore_fork)) != 0) |
# else |
# else |
while(sem_wait((*s_etat_processus).semaphore_fork) |
while(sem_wait((*s_etat_processus).semaphore_fork) |
!= 0) |
!= 0) |
# endif |
# endif |
{ |
{ |
if (errno != EINTR) |
if (errno != EINTR) |
Line 3050 instruction_wfsock(struct_processus *s_e
|
Line 3453 instruction_wfsock(struct_processus *s_e
|
} |
} |
else |
else |
{ |
{ |
# ifndef SEMAPHORES_NOMMES |
# ifndef SEMAPHORES_NOMMES |
while(sem_wait(&((*s_etat_processus) |
while(sem_wait(&((*s_etat_processus) |
.semaphore_fork)) != 0) |
.semaphore_fork)) != 0) |
# else |
# else |
while(sem_wait((*s_etat_processus).semaphore_fork) |
while(sem_wait((*s_etat_processus).semaphore_fork) |
!= 0) |
!= 0) |
# endif |
# endif |
{ |
{ |
if (errno != EINTR) |
if (errno != EINTR) |
{ |
{ |
Line 3065 instruction_wfsock(struct_processus *s_e
|
Line 3468 instruction_wfsock(struct_processus *s_e
|
return; |
return; |
} |
} |
} |
} |
|
|
|
if (options_sockets(s_etat_processus, |
|
(*s_objet_resultat).objet) != d_absence_erreur) |
|
{ |
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_parametre_fichier; |
|
return; |
|
} |
} |
} |
} while(drapeau == d_faux); |
} while(drapeau == d_faux); |
|
|
|
printf("socket: %d\n", (*((struct_socket *) (*s_objet_resultat).objet)).socket); |
if (((*((struct_socket *) (*s_objet_resultat).objet)) |
if (((*((struct_socket *) (*s_objet_resultat).objet)) |
.adresse_distante = malloc(22 * |
.adresse_distante = malloc(22 * |
sizeof(unsigned char))) == NULL) |
sizeof(unsigned char))) == NULL) |
Line 3095 instruction_wfsock(struct_processus *s_e
|
Line 3510 instruction_wfsock(struct_processus *s_e
|
{ |
{ |
drapeau = d_vrai; |
drapeau = d_vrai; |
|
|
# ifndef SEMAPHORES_NOMMES |
# ifndef SEMAPHORES_NOMMES |
if (sem_post(&((*s_etat_processus).semaphore_fork)) |
if (sem_post(&((*s_etat_processus).semaphore_fork)) |
!= 0) |
!= 0) |
# else |
# else |
if (sem_post((*s_etat_processus).semaphore_fork) != 0) |
if (sem_post((*s_etat_processus).semaphore_fork) != 0) |
# endif |
# endif |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
Line 3113 instruction_wfsock(struct_processus *s_e
|
Line 3528 instruction_wfsock(struct_processus *s_e
|
{ |
{ |
erreur = errno; |
erreur = errno; |
|
|
# ifndef SEMAPHORES_NOMMES |
# ifndef SEMAPHORES_NOMMES |
while(sem_wait(&((*s_etat_processus) |
while(sem_wait(&((*s_etat_processus) |
.semaphore_fork)) != 0) |
.semaphore_fork)) != 0) |
# else |
# else |
while(sem_wait((*s_etat_processus).semaphore_fork) |
while(sem_wait((*s_etat_processus).semaphore_fork) |
!= 0) |
!= 0) |
# endif |
# endif |
{ |
{ |
if (errno != EINTR) |
if (errno != EINTR) |
{ |
{ |
Line 3152 instruction_wfsock(struct_processus *s_e
|
Line 3567 instruction_wfsock(struct_processus *s_e
|
} |
} |
else |
else |
{ |
{ |
# ifndef SEMAPHORES_NOMMES |
# ifndef SEMAPHORES_NOMMES |
while(sem_wait(&((*s_etat_processus) |
while(sem_wait(&((*s_etat_processus) |
.semaphore_fork)) != 0) |
.semaphore_fork)) != 0) |
# else |
# else |
while(sem_wait((*s_etat_processus).semaphore_fork) |
while(sem_wait((*s_etat_processus).semaphore_fork) |
!= 0) |
!= 0) |
# endif |
# endif |
{ |
{ |
if (errno != EINTR) |
if (errno != EINTR) |
{ |
{ |
Line 3167 instruction_wfsock(struct_processus *s_e
|
Line 3582 instruction_wfsock(struct_processus *s_e
|
return; |
return; |
} |
} |
} |
} |
|
|
|
if (options_sockets(s_etat_processus, |
|
(*s_objet_resultat).objet) != d_absence_erreur) |
|
{ |
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_parametre_fichier; |
|
return; |
|
} |
} |
} |
} 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 3179 instruction_wfsock(struct_processus *s_e
|
Line 3605 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 3217 instruction_wfsock(struct_processus *s_e
|
Line 3647 instruction_wfsock(struct_processus *s_e
|
{ |
{ |
drapeau = d_vrai; |
drapeau = d_vrai; |
|
|
# ifndef SEMAPHORES_NOMMES |
# ifndef SEMAPHORES_NOMMES |
if (sem_post(&((*s_etat_processus).semaphore_fork)) |
if (sem_post(&((*s_etat_processus).semaphore_fork)) |
!= 0) |
!= 0) |
# else |
# else |
if (sem_post((*s_etat_processus).semaphore_fork) != 0) |
if (sem_post((*s_etat_processus).semaphore_fork) != 0) |
# endif |
# endif |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
Line 3235 instruction_wfsock(struct_processus *s_e
|
Line 3665 instruction_wfsock(struct_processus *s_e
|
{ |
{ |
erreur = errno; |
erreur = errno; |
|
|
# ifndef SEMAPHORES_NOMMES |
# ifndef SEMAPHORES_NOMMES |
while(sem_wait(&((*s_etat_processus) |
while(sem_wait(&((*s_etat_processus) |
.semaphore_fork)) != 0) |
.semaphore_fork)) != 0) |
# else |
# else |
while(sem_wait((*s_etat_processus).semaphore_fork) |
while(sem_wait((*s_etat_processus).semaphore_fork) |
!= 0) |
!= 0) |
# endif |
# endif |
{ |
{ |
if (errno != EINTR) |
if (errno != EINTR) |
{ |
{ |
Line 3274 instruction_wfsock(struct_processus *s_e
|
Line 3704 instruction_wfsock(struct_processus *s_e
|
} |
} |
else |
else |
{ |
{ |
# ifndef SEMAPHORES_NOMMES |
# ifndef SEMAPHORES_NOMMES |
while(sem_wait(&((*s_etat_processus) |
while(sem_wait(&((*s_etat_processus) |
.semaphore_fork)) != 0) |
.semaphore_fork)) != 0) |
# else |
# else |
while(sem_wait((*s_etat_processus).semaphore_fork) |
while(sem_wait((*s_etat_processus).semaphore_fork) |
!= 0) |
!= 0) |
# endif |
# endif |
{ |
{ |
if (errno != EINTR) |
if (errno != EINTR) |
{ |
{ |
Line 3289 instruction_wfsock(struct_processus *s_e
|
Line 3719 instruction_wfsock(struct_processus *s_e
|
return; |
return; |
} |
} |
} |
} |
|
|
|
if (options_sockets(s_etat_processus, |
|
(*s_objet_resultat).objet) != d_absence_erreur) |
|
{ |
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_parametre_fichier; |
|
return; |
|
} |
} |
} |
} while(drapeau == d_faux); |
} while(drapeau == d_faux); |
} |
} |
Line 3459 instruction_wfswi(struct_processus *s_et
|
Line 3900 instruction_wfswi(struct_processus *s_et
|
return; |
return; |
} |
} |
|
|
|
if (pthread_mutex_lock(&(*s_etat_processus).mutex_interruptions) |
|
!= 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
|
if ((*s_etat_processus).nombre_interruptions_non_affectees != 0) |
if ((*s_etat_processus).nombre_interruptions_non_affectees != 0) |
{ |
{ |
affectation_interruptions_logicielles(s_etat_processus); |
affectation_interruptions_logicielles(s_etat_processus); |
} |
} |
|
|
|
if (pthread_mutex_unlock(&(*s_etat_processus).mutex_interruptions) |
|
!= 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
|
if ((*s_etat_processus).queue_interruptions[interruption - 1] > 0) |
if ((*s_etat_processus).queue_interruptions[interruption - 1] > 0) |
{ |
{ |
drapeau_fin = d_vrai; |
drapeau_fin = d_vrai; |
} |
} |
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); |
} |
} |
Line 3596 instruction_wfpoke(struct_processus *s_e
|
Line 4074 instruction_wfpoke(struct_processus *s_e
|
|
|
scrutation_injection(s_etat_processus); |
scrutation_injection(s_etat_processus); |
|
|
|
if (pthread_mutex_lock(&(*s_etat_processus).mutex_interruptions) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
|
if ((*s_etat_processus).nombre_interruptions_non_affectees != 0) |
if ((*s_etat_processus).nombre_interruptions_non_affectees != 0) |
{ |
{ |
affectation_interruptions_logicielles(s_etat_processus); |
affectation_interruptions_logicielles(s_etat_processus); |
} |
} |
|
|
|
if (pthread_mutex_unlock(&(*s_etat_processus).mutex_interruptions) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
|
if ((*s_etat_processus).nombre_interruptions_en_queue != 0) |
if ((*s_etat_processus).nombre_interruptions_en_queue != 0) |
{ |
{ |
registre_instruction_valide = |
registre_instruction_valide = |
Line 3703 instruction_wfack(struct_processus *s_et
|
Line 4193 instruction_wfack(struct_processus *s_et
|
{ |
{ |
scrutation_injection(s_etat_processus); |
scrutation_injection(s_etat_processus); |
|
|
|
if (pthread_mutex_lock(&(*s_etat_processus).mutex_interruptions) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
|
if ((*s_etat_processus).nombre_interruptions_non_affectees != 0) |
if ((*s_etat_processus).nombre_interruptions_non_affectees != 0) |
{ |
{ |
affectation_interruptions_logicielles(s_etat_processus); |
affectation_interruptions_logicielles(s_etat_processus); |
} |
} |
|
|
|
if (pthread_mutex_unlock(&(*s_etat_processus).mutex_interruptions) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
|
if ((*s_etat_processus).nombre_interruptions_en_queue != 0) |
if ((*s_etat_processus).nombre_interruptions_en_queue != 0) |
{ |
{ |
registre_instruction_valide = |
registre_instruction_valide = |