From 8610b03518c17cbfcbc38198765554b90a2fc6a9 Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Sat, 2 Jun 2018 15:00:01 +0200 Subject: Reset the communication buffer as expected. --- src/analysis/db/client.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/analysis/db/client.c b/src/analysis/db/client.c index f70c9e1..5999b70 100644 --- a/src/analysis/db/client.c +++ b/src/analysis/db/client.c @@ -503,8 +503,8 @@ static bool g_db_client_start_common(GDbClient *client, const char *desc) static void *g_db_client_update(GDbClient *client) { struct pollfd fds; /* Surveillance des flux */ - int ret; /* Bilan d'un appel */ packed_buffer in_pbuf; /* Tampon de réception */ + int ret; /* Bilan d'un appel */ uint32_t tmp32; /* Valeur sur 32 bits */ bool status; /* Bilan d'une opération */ uint32_t command; /* Commande de la requête */ @@ -514,6 +514,8 @@ static void *g_db_client_update(GDbClient *client) fds.fd = client->fd; fds.events = POLLIN | POLLPRI; + init_packed_buffer(&in_pbuf); + while (1) { ret = poll(&fds, 1, -1); @@ -525,6 +527,8 @@ static void *g_db_client_update(GDbClient *client) if (fds.revents & (POLLIN | POLLPRI)) { + reset_packed_buffer(&in_pbuf); + status = recv_packed_buffer(&in_pbuf, fds.fd); if (!status) goto gdcu_bad_exchange; @@ -564,16 +568,12 @@ static void *g_db_client_update(GDbClient *client) } - exit_packed_buffer(&in_pbuf); - continue; gdcu_bad_exchange: printf("Bad reception...\n"); - exit_packed_buffer(&in_pbuf); - /* TODO : close conn */ ; @@ -586,6 +586,8 @@ static void *g_db_client_update(GDbClient *client) //g_db_client_stop(client); + exit_packed_buffer(&in_pbuf); + return NULL; } -- cgit v0.11.2-87-g4458