Migration to new guac_read_instruction(), remove use of guac_free_instruction_data().

This commit is contained in:
Michael Jumper 2011-11-24 18:25:33 -08:00
parent 0db81b73ac
commit 66a0ff52ee

View File

@ -74,9 +74,6 @@ void* __guac_client_output_thread(void* data) {
/* Handle server messages */ /* Handle server messages */
if (client->handle_messages) { if (client->handle_messages) {
/* Get previous GUACIO state */
int last_total_written = io->total_written;
/* Only handle messages if synced within threshold */ /* Only handle messages if synced within threshold */
if (client->last_sent_timestamp - client->last_received_timestamp if (client->last_sent_timestamp - client->last_received_timestamp
< GUAC_SYNC_THRESHOLD) { < GUAC_SYNC_THRESHOLD) {
@ -88,19 +85,14 @@ void* __guac_client_output_thread(void* data) {
return NULL; return NULL;
} }
/* If data was written during message handling */ /* Sleep as necessary */
if (io->total_written != last_total_written) { guac_sleep(GUAC_SERVER_MESSAGE_HANDLE_FREQUENCY);
/* Sleep as necessary */
guac_sleep(GUAC_SERVER_MESSAGE_HANDLE_FREQUENCY);
/* Send sync instruction */
client->last_sent_timestamp = guac_current_timestamp();
if (guac_send_sync(io, client->last_sent_timestamp)) {
guac_client_stop(client);
return NULL;
}
/* Send sync instruction */
client->last_sent_timestamp = guac_current_timestamp();
if (guac_send_sync(io, client->last_sent_timestamp)) {
guac_client_stop(client);
return NULL;
} }
if (guac_flush(io)) { if (guac_flush(io)) {
@ -132,23 +124,31 @@ void* __guac_client_input_thread(void* data) {
guac_client* client = (guac_client*) data; guac_client* client = (guac_client*) data;
GUACIO* io = client->io; GUACIO* io = client->io;
guac_instruction instruction;
/* Guacamole client input loop */ /* Guacamole client input loop */
while (client->state == RUNNING && guac_read_instruction(io, GUAC_USEC_TIMEOUT, &instruction) > 0) { while (client->state == RUNNING) {
/* Call handler, stop on error */ /* Read instruction */
if (guac_client_handle_instruction(client, &instruction) < 0) { guac_instruction* instruction =
guac_free_instruction_data(&instruction); guac_read_instruction(io, GUAC_USEC_TIMEOUT);
break;
/* Stop on error */
if (instruction == NULL) {
guac_client_stop(client);
return NULL;
} }
/* Free allocate instruction data */ /* Call handler, stop on error */
guac_free_instruction_data(&instruction); if (guac_client_handle_instruction(client, instruction) < 0) {
guac_free_instruction(instruction);
guac_client_stop(client);
return NULL;
}
/* Free allocated instruction */
guac_free_instruction(instruction);
} }
guac_client_stop(client);
return NULL; return NULL;
} }