summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-06-02 13:00:01 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-06-02 13:00:01 (GMT)
commit8610b03518c17cbfcbc38198765554b90a2fc6a9 (patch)
tree627acc291aaadb767ba7707280bebe026dfc78c2 /src
parent7ebe360e85dceb8db580fd76ec8f4d6865e8a5aa (diff)
Reset the communication buffer as expected.
Diffstat (limited to 'src')
-rw-r--r--src/analysis/db/client.c12
1 files 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;
}