From 39f195df214c0da73f5c4cd87485b72f15e9c58d Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 24 Nov 2011 18:51:05 -0800 Subject: [PATCH] Added logging to client threads --- src/client.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/client.c b/src/client.c index 6570f96..b4e9212 100644 --- a/src/client.c +++ b/src/client.c @@ -40,6 +40,7 @@ #include #include #include +#include #include "client.h" #include "thread.h" @@ -61,14 +62,24 @@ void* __guac_client_output_thread(void* data) { /* Occasionally ping client with repeat of last sync */ guac_timestamp timestamp = guac_current_timestamp(); if (timestamp - last_ping_timestamp > GUAC_SYNC_FREQUENCY) { + + /* Record time of last synnc */ last_ping_timestamp = timestamp; - if ( - guac_send_sync(io, client->last_sent_timestamp) - || guac_flush(io) - ) { + + /* Send sync */ + if (guac_send_sync(io, client->last_sent_timestamp)) { + guac_log_error("Error sending \"sync\" instruction: %s", guac_status_string(guac_error)); guac_client_stop(client); return NULL; } + + /* Flush */ + if (guac_flush(io)) { + guac_log_error("Error flushing output: %s", guac_status_string(guac_error)); + guac_client_stop(client); + return NULL; + } + } /* Handle server messages */ @@ -80,7 +91,7 @@ void* __guac_client_output_thread(void* data) { int retval = client->handle_messages(client); if (retval) { - guac_log_error("Error handling server messages"); + guac_log_error("Error handling server messages: %s", guac_status_string(guac_error)); guac_client_stop(client); return NULL; } @@ -91,11 +102,13 @@ void* __guac_client_output_thread(void* data) { /* Send sync instruction */ client->last_sent_timestamp = guac_current_timestamp(); if (guac_send_sync(io, client->last_sent_timestamp)) { + guac_log_error("Error sending \"sync\" instruction: %s", guac_status_string(guac_error)); guac_client_stop(client); return NULL; } if (guac_flush(io)) { + guac_log_error("Error flushing output: %s", guac_status_string(guac_error)); guac_client_stop(client); return NULL; } @@ -133,12 +146,14 @@ void* __guac_client_input_thread(void* data) { /* Stop on error */ if (instruction == NULL) { + guac_log_error("Error reading instruction: %s", guac_status_string(guac_error)); guac_client_stop(client); return NULL; } /* Call handler, stop on error */ if (guac_client_handle_instruction(client, instruction) < 0) { + guac_log_error("Error in client \"%s\" instruction handler: %s", instruction->opcode, guac_status_string(guac_error)); guac_free_instruction(instruction); guac_client_stop(client); return NULL; -- 1.7.10.4