version 1.55, 2013/02/26 19:56:16
|
version 1.94, 2025/04/15 10:17:55
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.1.12 |
RPL/2 (R) version 4.1.36 |
Copyright (C) 1989-2013 Dr. BERTRAND Joël |
Copyright (C) 1989-2025 Dr. BERTRAND Joël |
|
|
This file is part of RPL/2. |
This file is part of RPL/2. |
|
|
Line 102 instruction_splash(struct_processus *s_e
|
Line 102 instruction_splash(struct_processus *s_e
|
return; |
return; |
} |
} |
|
|
encart(s_etat_processus, (unsigned long) (attente * 1E6)); |
encart(s_etat_processus, (integer8) (attente * 1E6)); |
} |
} |
else |
else |
{ |
{ |
Line 133 instruction_splash(struct_processus *s_e
|
Line 133 instruction_splash(struct_processus *s_e
|
void |
void |
instruction_send(struct_processus *s_etat_processus) |
instruction_send(struct_processus *s_etat_processus) |
{ |
{ |
pid_t pid; |
|
|
|
pthread_t tid; |
|
|
|
sig_atomic_t registre; |
sig_atomic_t registre; |
|
|
ssize_t longueur_ecriture; |
ssize_t longueur_ecriture; |
Line 145 instruction_send(struct_processus *s_eta
|
Line 141 instruction_send(struct_processus *s_eta
|
|
|
struct timespec attente; |
struct timespec attente; |
|
|
|
unsigned char caractere; |
unsigned char tampon; |
unsigned char tampon; |
|
|
(*s_etat_processus).erreur_execution = d_ex; |
(*s_etat_processus).erreur_execution = d_ex; |
Line 242 instruction_send(struct_processus *s_eta
|
Line 239 instruction_send(struct_processus *s_eta
|
} |
} |
} |
} |
|
|
pid = -3; |
|
|
|
attente.tv_sec = 0; |
|
attente.tv_nsec = GRANULARITE_us * 1000; |
|
|
|
# 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 |
Line 257 instruction_send(struct_processus *s_eta
|
Line 249 instruction_send(struct_processus *s_eta
|
return; |
return; |
} |
} |
|
|
while((longueur_ecriture = write_atomic(s_etat_processus, |
caractere = 1; |
(*s_etat_processus).pipe_nombre_objets_attente, |
|
&pid, sizeof(pid))) != sizeof(pid)) |
|
{ |
|
# 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 (longueur_ecriture == -1) |
|
{ |
|
if ((*s_etat_processus).profilage == d_vrai) |
|
{ |
|
profilage(s_etat_processus, NULL); |
|
} |
|
|
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
|
|
nanosleep(&attente, NULL); |
|
INCR_GRANULARITE(attente.tv_nsec); |
|
|
|
# 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; |
|
} |
|
|
|
scrutation_interruptions(s_etat_processus); |
|
} |
|
|
|
pid = getpid(); |
|
|
|
attente.tv_sec = 0; |
attente.tv_sec = 0; |
attente.tv_nsec = GRANULARITE_us * 1000; |
attente.tv_nsec = GRANULARITE_us * 1000; |
|
|
while((longueur_ecriture = write_atomic(s_etat_processus, |
while((longueur_ecriture = write_atomic(s_etat_processus, |
(*s_etat_processus).pipe_nombre_objets_attente, |
(*s_etat_processus).pipe_nombre_elements_attente, |
&pid, sizeof(pid))) != sizeof(pid)) |
&caractere, sizeof(caractere))) != sizeof(caractere)) |
{ |
{ |
# ifndef SEMAPHORES_NOMMES |
# ifndef SEMAPHORES_NOMMES |
while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0) |
while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0) |
Line 375 instruction_send(struct_processus *s_eta
|
Line 323 instruction_send(struct_processus *s_eta
|
} |
} |
} |
} |
|
|
tid = (pthread_t) -3; |
|
|
|
attente.tv_sec = 0; |
attente.tv_sec = 0; |
attente.tv_nsec = GRANULARITE_us * 1000; |
attente.tv_nsec = GRANULARITE_us * 1000; |
|
|
Line 390 instruction_send(struct_processus *s_eta
|
Line 336 instruction_send(struct_processus *s_eta
|
return; |
return; |
} |
} |
|
|
while((longueur_ecriture = write_atomic(s_etat_processus, |
caractere = 1; |
(*s_etat_processus).pipe_nombre_objets_attente, |
|
&tid, sizeof(tid))) != sizeof(tid)) |
|
{ |
|
# ifndef SEMAPHORES_NOMMES |
|
while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0) |
|
# else |
|
while(sem_wait((*s_etat_processus).semaphore_fork) != 0) |
|
# endif |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
|
|
if (longueur_ecriture == -1) |
|
{ |
|
if ((*s_etat_processus).profilage == d_vrai) |
|
{ |
|
profilage(s_etat_processus, NULL); |
|
} |
|
|
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
|
|
nanosleep(&attente, NULL); |
|
INCR_GRANULARITE(attente.tv_nsec); |
|
|
|
# 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; |
|
} |
|
|
|
scrutation_interruptions(s_etat_processus); |
|
} |
|
|
|
tid = pthread_self(); |
|
|
|
attente.tv_sec = 0; |
attente.tv_sec = 0; |
attente.tv_nsec = GRANULARITE_us * 1000; |
attente.tv_nsec = GRANULARITE_us * 1000; |
|
|
while((longueur_ecriture = write_atomic(s_etat_processus, |
while((longueur_ecriture = write_atomic(s_etat_processus, |
(*s_etat_processus).pipe_nombre_objets_attente, |
(*s_etat_processus).pipe_nombre_elements_attente, |
&tid, sizeof(tid))) != sizeof(tid)) |
&caractere, sizeof(caractere))) != sizeof(caractere)) |
{ |
{ |
# ifndef SEMAPHORES_NOMMES |
# ifndef SEMAPHORES_NOMMES |
while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0) |
while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0) |
Line 481 instruction_send(struct_processus *s_eta
|
Line 386 instruction_send(struct_processus *s_eta
|
} |
} |
|
|
# ifndef SEMAPHORES_NOMMES |
# ifndef SEMAPHORES_NOMMES |
if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) |
while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0) |
# else |
# else |
if (sem_post((*s_etat_processus).semaphore_fork) != 0) |
while(sem_wait((*s_etat_processus).semaphore_fork) != 0) |
# endif |
# endif |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
if (errno != EINTR) |
return; |
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
} |
} |
} |
} |
|
|
Line 551 instruction_send(struct_processus *s_eta
|
Line 459 instruction_send(struct_processus *s_eta
|
} |
} |
} |
} |
|
|
// Envoi d'un PID invalide (-1) pour ne pas bloquer le thread |
|
// de surveillance. |
|
|
|
if ((*s_etat_processus).processus_detache == d_vrai) |
|
{ |
|
pid = -1; |
|
|
|
attente.tv_sec = 0; |
|
attente.tv_nsec = GRANULARITE_us * 1000; |
|
|
|
# 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; |
|
} |
|
|
|
while((longueur_ecriture = write_atomic(s_etat_processus, |
|
(*s_etat_processus).pipe_nombre_interruptions_attente, |
|
&pid, sizeof(pid))) != sizeof(pid)) |
|
{ |
|
# 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 (longueur_ecriture == -1) |
|
{ |
|
if ((*s_etat_processus).profilage == d_vrai) |
|
{ |
|
profilage(s_etat_processus, NULL); |
|
} |
|
|
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
|
|
nanosleep(&attente, NULL); |
|
INCR_GRANULARITE(attente.tv_nsec); |
|
|
|
# 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; |
|
} |
|
} |
|
|
|
scrutation_interruptions(s_etat_processus); |
|
} |
|
else |
|
{ |
|
tid = (pthread_t) -1; |
|
|
|
attente.tv_sec = 0; |
|
attente.tv_nsec = GRANULARITE_us * 1000; |
|
|
|
# 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; |
|
} |
|
|
|
while((longueur_ecriture = write_atomic(s_etat_processus, |
|
(*s_etat_processus).pipe_nombre_interruptions_attente, |
|
&tid, sizeof(tid))) != sizeof(tid)) |
|
{ |
|
# 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 (longueur_ecriture == -1) |
|
{ |
|
if ((*s_etat_processus).profilage == d_vrai) |
|
{ |
|
profilage(s_etat_processus, NULL); |
|
} |
|
|
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
|
|
nanosleep(&attente, NULL); |
|
INCR_GRANULARITE(attente.tv_nsec); |
|
|
|
# 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; |
|
} |
|
|
|
scrutation_interruptions(s_etat_processus); |
|
} |
|
|
|
# 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; |
|
} |
|
} |
|
} |
|
|
|
// ecriture_pipe() ne peut être interrompu par un signal. |
// ecriture_pipe() ne peut être interrompu par un signal. |
|
|
# ifndef SEMAPHORES_NOMMES |
# ifndef SEMAPHORES_NOMMES |
Line 1131 instruction_sqlquery(struct_processus *s
|
Line 890 instruction_sqlquery(struct_processus *s
|
.descripteur.mysql); |
.descripteur.mysql); |
} |
} |
|
|
if (presence_resultat == d_vrai) |
if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile), |
|
s_objet_resultat) == d_erreur) |
{ |
{ |
if (empilement(s_etat_processus, |
return; |
&((*s_etat_processus).l_base_pile), |
|
s_objet_resultat) == d_erreur) |
|
{ |
|
return; |
|
} |
|
} |
} |
|
|
# else |
# else |
Line 1165 instruction_sqlquery(struct_processus *s
|
Line 920 instruction_sqlquery(struct_processus *s
|
{ |
{ |
# ifdef POSTGRESQL_SUPPORT |
# ifdef POSTGRESQL_SUPPORT |
|
|
unsigned int i; |
int i; |
unsigned int j; |
int j; |
unsigned int nombre_colonnes; |
int nombre_colonnes; |
unsigned int nombre_lignes; |
int nombre_lignes; |
|
|
logical1 presence_resultat; |
logical1 presence_resultat; |
|
|
Line 1343 instruction_sqlquery(struct_processus *s
|
Line 1098 instruction_sqlquery(struct_processus *s
|
else |
else |
{ |
{ |
if (((*(*l_element_courant_ligne).donnee).objet |
if (((*(*l_element_courant_ligne).donnee).objet |
= malloc((PQgetlength( |
= malloc(((size_t) (PQgetlength( |
resultat_postgresql, i, j) + 1) * |
resultat_postgresql, i, j) + 1)) * |
sizeof(unsigned char))) == NULL) |
sizeof(unsigned char))) == NULL) |
{ |
{ |
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
Line 1427 instruction_sqlquery(struct_processus *s
|
Line 1182 instruction_sqlquery(struct_processus *s
|
const char *queue; |
const char *queue; |
const unsigned char *resultat; |
const unsigned char *resultat; |
|
|
|
int i; |
int ios; |
int ios; |
|
int nombre_colonnes; |
logical1 presence_resultat; |
|
|
|
sqlite3_stmt *ppStmt; |
sqlite3_stmt *ppStmt; |
|
|
Line 1440 instruction_sqlquery(struct_processus *s
|
Line 1195 instruction_sqlquery(struct_processus *s
|
|
|
struct timespec attente; |
struct timespec attente; |
|
|
unsigned int i; |
|
unsigned int nombre_colonnes; |
|
|
|
if (sqlite3_prepare_v2((*((struct_connecteur_sql *) |
if (sqlite3_prepare_v2((*((struct_connecteur_sql *) |
(*s_objet_1).objet)).descripteur.sqlite, |
(*s_objet_1).objet)).descripteur.sqlite, |
(unsigned char *) (*s_objet_2).objet, |
(unsigned char *) (*s_objet_2).objet, |
strlen((unsigned char *) (*s_objet_2).objet), |
(int) strlen((unsigned char *) (*s_objet_2).objet), |
&ppStmt, &queue) != SQLITE_OK) |
&ppStmt, &queue) != SQLITE_OK) |
{ |
{ |
if (connexion_permanente == d_faux) |
if (connexion_permanente == d_faux) |
Line 1462 instruction_sqlquery(struct_processus *s
|
Line 1214 instruction_sqlquery(struct_processus *s
|
return; |
return; |
} |
} |
|
|
presence_resultat = d_faux; |
|
s_objet_resultat = NULL; |
s_objet_resultat = NULL; |
l_element_courant = NULL; |
l_element_courant = NULL; |
|
|
attente.tv_sec = 0; |
attente.tv_sec = 0; |
attente.tv_nsec = GRANULARITE_us * 1000; |
attente.tv_nsec = GRANULARITE_us * 1000; |
|
|
|
if ((s_objet_resultat = |
|
allocation(s_etat_processus, LST)) == NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return; |
|
} |
|
|
|
// Création d'une liste vide |
|
|
|
(*s_objet_resultat).objet = NULL; |
|
l_element_courant = (*s_objet_resultat).objet; |
|
|
do |
do |
{ |
{ |
switch(ios = sqlite3_step(ppStmt)) |
switch(ios = sqlite3_step(ppStmt)) |
{ |
{ |
case SQLITE_ROW: |
case SQLITE_ROW: |
{ |
{ |
if (s_objet_resultat == NULL) |
|
{ |
|
if ((s_objet_resultat = |
|
allocation(s_etat_processus, LST)) == NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return; |
|
} |
|
|
|
presence_resultat = d_vrai; |
|
|
|
// Création d'une liste vide |
|
|
|
(*s_objet_resultat).objet = NULL; |
|
l_element_courant = (*s_objet_resultat).objet; |
|
} |
|
|
|
// Ajout d'une liste au bout de la liste |
// Ajout d'une liste au bout de la liste |
// contenant les lignes |
// contenant les lignes |
|
|
Line 1662 instruction_sqlquery(struct_processus *s
|
Line 1408 instruction_sqlquery(struct_processus *s
|
.descripteur.sqlite); |
.descripteur.sqlite); |
} |
} |
|
|
if (presence_resultat == d_vrai) |
if (empilement(s_etat_processus, &((*s_etat_processus) |
|
.l_base_pile), s_objet_resultat) == d_erreur) |
{ |
{ |
if (empilement(s_etat_processus, &((*s_etat_processus) |
return; |
.l_base_pile), s_objet_resultat) == d_erreur) |
|
{ |
|
return; |
|
} |
|
} |
} |
} |
} |
else |
else |
Line 1761 instruction_stop(struct_processus *s_eta
|
Line 1504 instruction_stop(struct_processus *s_eta
|
.processus_detache == d_vrai) |
.processus_detache == d_vrai) |
{ |
{ |
envoi_signal_processus((*(*((struct_processus_fils *) |
envoi_signal_processus((*(*((struct_processus_fils *) |
(*s_objet).objet)).thread).pid, rpl_sigstop); |
(*s_objet).objet)).thread).pid, rpl_sigstop, d_faux); |
} |
} |
else |
else |
{ |
{ |
if (pthread_mutex_lock(&((*s_etat_processus).mutex)) != 0) |
if (pthread_mutex_lock(&((*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 1807 instruction_stop(struct_processus *s_eta
|
Line 1551 instruction_stop(struct_processus *s_eta
|
if (pthread_mutex_lock(&((*(*((struct_processus_fils *) |
if (pthread_mutex_lock(&((*(*((struct_processus_fils *) |
(*s_objet).objet)).thread).mutex)) != 0) |
(*s_objet).objet)).thread).mutex)) != 0) |
{ |
{ |
if (pthread_mutex_unlock(&((*s_etat_processus).mutex)) |
if (pthread_mutex_unlock(&((*s_etat_processus) |
!= 0) |
.mutex_pile_processus)) != 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
Line 1821 instruction_stop(struct_processus *s_eta
|
Line 1565 instruction_stop(struct_processus *s_eta
|
if ((*(*((struct_processus_fils *) |
if ((*(*((struct_processus_fils *) |
(*s_objet).objet)).thread).thread_actif == d_vrai) |
(*s_objet).objet)).thread).thread_actif == d_vrai) |
{ |
{ |
envoi_signal_thread((*(*((struct_processus_fils *) |
envoi_signal_thread(s_etat_processus, |
|
(*(*((struct_processus_fils *) |
(*s_objet).objet)).thread).tid, rpl_sigstop); |
(*s_objet).objet)).thread).tid, rpl_sigstop); |
} |
} |
|
|
if (pthread_mutex_unlock(&((*(*((struct_processus_fils *) |
if (pthread_mutex_unlock(&((*(*((struct_processus_fils *) |
(*s_objet).objet)).thread).mutex)) != 0) |
(*s_objet).objet)).thread).mutex)) != 0) |
{ |
{ |
if (pthread_mutex_unlock(&((*s_etat_processus).mutex)) |
if (pthread_mutex_unlock(&((*s_etat_processus) |
!= 0) |
.mutex_pile_processus)) != 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
Line 1841 instruction_stop(struct_processus *s_eta
|
Line 1586 instruction_stop(struct_processus *s_eta
|
} |
} |
} |
} |
|
|
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; |