version 1.64, 2012/06/22 10:12:19
|
version 1.74, 2013/03/01 10:24:49
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.1.9 |
RPL/2 (R) version 4.1.13 |
Copyright (C) 1989-2012 Dr. BERTRAND Joël |
Copyright (C) 1989-2013 Dr. BERTRAND Joël |
|
|
This file is part of RPL/2. |
This file is part of RPL/2. |
|
|
Line 385 instruction_write(struct_processus *s_et
|
Line 385 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; |
Line 424 instruction_write(struct_processus *s_et
|
Line 425 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 760 instruction_write(struct_processus *s_et
|
Line 763 instruction_write(struct_processus *s_et
|
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 917 instruction_write(struct_processus *s_et
|
Line 939 instruction_write(struct_processus *s_et
|
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(&commande, "insert into key " |
"(key) values ('%s')", clef_utf8) < 0) |
"(key) values ('%s')", clef_utf8) < 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
d_es_allocation_memoire; |
d_es_allocation_memoire; |
return; |
return; |
} |
} |
|
|
if (sqlite3_prepare_v2((*descripteur) |
if (sqlite3_prepare_v2((*descripteur) |
.descripteur_sqlite, |
.descripteur_sqlite, |
commande, strlen(commande), &ppStmt, &queue) |
commande, 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(&commande, "select id from key " |
"where key = '%s'", clef_utf8) < 0) |
"where key = '%s'", clef_utf8) < 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
d_es_allocation_memoire; |
d_es_allocation_memoire; |
return; |
return; |
|
} |
|
|
|
if (sqlite3_prepare_v2((*descripteur) |
|
.descripteur_sqlite, |
|
commande, 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; |
|
} |
} |
|
} while(sqlite_status != SQLITE_ROW); |
default: |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_erreur_fichier; |
|
return; |
|
} |
|
} |
|
|
|
if (sqlite3_column_type(ppStmt, 0) != SQLITE_INTEGER) |
if (sqlite3_column_type(ppStmt, 0) != SQLITE_INTEGER) |
{ |
{ |
Line 1403 instruction_write(struct_processus *s_et
|
Line 1432 instruction_write(struct_processus *s_et
|
|
|
longueur = strlen(format_chaine); |
longueur = strlen(format_chaine); |
|
|
if (format_chaine[longueur] != ')') |
if (format_chaine[longueur - 1] != ')') |
{ |
{ |
free(format_chaine); |
free(format_chaine); |
|
|
Line 1737 instruction_write(struct_processus *s_et
|
Line 1766 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 1789 instruction_write(struct_processus *s_et
|
Line 1824 instruction_write(struct_processus *s_et
|
longueur_effective, 0, (struct sockaddr *) |
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 1842 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 1872 instruction_write(struct_processus *s_et
|
Line 1923 instruction_write(struct_processus *s_et
|
longueur_effective, 0, (struct sockaddr *) |
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 1941 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; |