More error handling, style fix.

This commit is contained in:
Michael Jumper 2011-03-19 16:39:18 -07:00
parent 6300c7c56a
commit 71d59845e9
2 changed files with 30 additions and 13 deletions

View File

@ -190,9 +190,14 @@ guac_client* guac_get_client(int client_fd) {
return NULL;
}
/* Send args */
guac_send_args(io, client_args);
guac_flush(io);
if ( /* Send args */
guac_send_args(io, client_args)
|| guac_flush(io)
) {
guac_close(io);
guac_free_instruction_data(&instruction);
return NULL;
}
guac_free_instruction_data(&instruction);
break;
@ -292,8 +297,13 @@ void* __guac_client_output_thread(void* data) {
long timestamp = guac_current_timestamp();
if (timestamp - client->last_sent_timestamp > GUAC_SYNC_FREQUENCY) {
client->last_sent_timestamp = timestamp;
guac_send_sync(io, timestamp);
guac_flush(io);
if (
guac_send_sync(io, timestamp)
|| guac_flush(io)
) {
guac_client_stop(client);
return NULL;
}
}
/* Handle server messages */
@ -320,11 +330,18 @@ void* __guac_client_output_thread(void* data) {
/* Send sync instruction */
client->last_sent_timestamp = guac_current_timestamp();
guac_send_sync(io, client->last_sent_timestamp);
if (guac_send_sync(io, client->last_sent_timestamp)) {
guac_client_stop(client);
return NULL;
}
}
guac_flush(io);
if (guac_flush(io)) {
guac_client_stop(client);
return NULL;
}
}
/* If sync threshold exceeded, don't spin waiting for resync */

View File

@ -214,7 +214,7 @@ int guac_send_name(GUACIO* io, const char* name) {
int guac_send_size(GUACIO* io, int w, int h) {
return
guac_write_string(io, "size:")
guac_write_string(io, "size:")
|| guac_write_int(io, w)
|| guac_write_string(io, ",")
|| guac_write_int(io, h)
@ -227,7 +227,7 @@ int guac_send_clipboard(GUACIO* io, const char* data) {
char* escaped = guac_escape_string(data);
if (
guac_write_string(io, "clipboard:")
guac_write_string(io, "clipboard:")
|| guac_write_string(io, escaped)
|| guac_write_string(io, ";")
) {
@ -245,7 +245,7 @@ int guac_send_error(GUACIO* io, const char* error) {
char* escaped = guac_escape_string(error);
if (
guac_write_string(io, "error:")
guac_write_string(io, "error:")
|| guac_write_string(io, escaped)
|| guac_write_string(io, ";")
) {
@ -261,7 +261,7 @@ int guac_send_error(GUACIO* io, const char* error) {
int guac_send_sync(GUACIO* io, long timestamp) {
return
guac_write_string(io, "sync:")
guac_write_string(io, "sync:")
|| guac_write_int(io, timestamp)
|| guac_write_string(io, ";");
@ -270,7 +270,7 @@ int guac_send_sync(GUACIO* io, long timestamp) {
int guac_send_copy(GUACIO* io, int srcl, int srcx, int srcy, int w, int h, int dstl, int dstx, int dsty) {
return
guac_write_string(io, "copy:")
guac_write_string(io, "copy:")
|| guac_write_int(io, srcl)
|| guac_write_string(io, ",")
|| guac_write_int(io, srcx)
@ -419,7 +419,7 @@ int guac_send_cursor(GUACIO* io, int x, int y, png_byte** png_rows, int w, int h
);
if (
guac_write_string(io, "cursor:")
guac_write_string(io, "cursor:")
|| guac_write_int(io, x)
|| guac_write_string(io, ",")
|| guac_write_int(io, y)