diff --git a/guacamole/src/libguac/guacamole/protocol.h b/guacamole/src/libguac/guacamole/protocol.h index 45c0099..0838874 100644 --- a/guacamole/src/libguac/guacamole/protocol.h +++ b/guacamole/src/libguac/guacamole/protocol.h @@ -120,18 +120,6 @@ int guac_protocol_send_error(guac_socket* socket, const char* error, int guac_protocol_send_mouse(guac_socket* socket, int x, int y, int button_mask, guac_timestamp timestamp); -/** - * Sends a nop instruction (null-operation) over the given guac_socket - * connection. - * - * If an error occurs sending the instruction, a non-zero value is - * returned, and guac_error is set appropriately. - * - * @param socket The guac_socket connection to use. - * @return Zero on success, non-zero on error. - */ -int guac_protocol_send_nop(guac_socket* socket); - /** * Sends a sync instruction over the given guac_socket connection. The * current time in milliseconds should be passed in as the timestamp. diff --git a/guacamole/src/libguac/guacamole/socket-constants.h b/guacamole/src/libguac/guacamole/socket-constants.h index 60f06c5..2f9d51e 100644 --- a/guacamole/src/libguac/guacamole/socket-constants.h +++ b/guacamole/src/libguac/guacamole/socket-constants.h @@ -31,11 +31,5 @@ */ #define GUAC_SOCKET_OUTPUT_BUFFER_SIZE 8192 -/** - * The number of milliseconds to wait between keep-alive pings on a socket - * with keep-alive enabled. - */ -#define GUAC_SOCKET_KEEP_ALIVE_INTERVAL 5000 - #endif diff --git a/guacamole/src/libguac/guacamole/socket.h b/guacamole/src/libguac/guacamole/socket.h index 2a023de..c0ac213 100644 --- a/guacamole/src/libguac/guacamole/socket.h +++ b/guacamole/src/libguac/guacamole/socket.h @@ -103,16 +103,6 @@ struct guac_socket { */ int __ready_buf[3]; - /** - * Whether automatic keep-alive is enabled. - */ - int __keep_alive_enabled; - - /** - * The keep-alive thread. - */ - pthread_t __keep_alive_thread; - }; /** @@ -131,15 +121,6 @@ guac_socket* guac_socket_alloc(); */ void guac_socket_free(guac_socket* socket); -/** - * Declares that the given socket must automatically send a keep-alive ping - * to ensure neither side of the socket times out while the socket is open. - * This ping will take the form of a "nop" instruction. - * - * @param socket - * The guac_socket to declare as requiring an automatic keep-alive ping. - */ -void guac_socket_require_keep_alive(guac_socket* socket); /** * Marks the beginning of a Guacamole protocol instruction. diff --git a/guacamole/src/libguac/protocol.c b/guacamole/src/libguac/protocol.c index e2fe605..af1aced 100644 --- a/guacamole/src/libguac/protocol.c +++ b/guacamole/src/libguac/protocol.c @@ -420,18 +420,6 @@ int guac_protocol_send_name(guac_socket* socket, const char* name) { } -int guac_protocol_send_nop(guac_socket* socket) { - - int ret_val; - - guac_socket_instruction_begin(socket); - ret_val = guac_socket_write_string(socket, "3.nop;"); - guac_socket_instruction_end(socket); - - return ret_val; - -} - int guac_protocol_send_pipe(guac_socket* socket, const guac_stream* stream, const char* mimetype, const char* name) { diff --git a/guacamole/src/libguac/socket.c b/guacamole/src/libguac/socket.c index 6bc0036..01944e7 100644 --- a/guacamole/src/libguac/socket.c +++ b/guacamole/src/libguac/socket.c @@ -42,38 +42,6 @@ char __guac_socket_BASE64_CHARACTERS[64] = { '8', '9', '+', '/' }; -static void* __guac_socket_keep_alive_thread(void* data) { - - /* Calculate sleep interval */ - struct timespec interval; - interval.tv_sec = GUAC_SOCKET_KEEP_ALIVE_INTERVAL / 1000; - interval.tv_nsec = (GUAC_SOCKET_KEEP_ALIVE_INTERVAL % 1000) * 1000000L; - - /* Socket keep-alive loop */ - guac_socket* socket = (guac_socket*) data; - while (socket->state == GUAC_SOCKET_OPEN) { - - /* Send NOP keep-alive if it's been a while since the last output */ - guac_timestamp timestamp = guac_timestamp_current(); - if (timestamp - socket->last_write_timestamp > - GUAC_SOCKET_KEEP_ALIVE_INTERVAL) { - - /* Send NOP */ - if (guac_protocol_send_nop(socket) - || guac_socket_flush(socket)) - break; - - } - - /* Sleep until next keep-alive check */ - nanosleep(&interval, NULL); - - } - - return NULL; - -} - static ssize_t __guac_socket_write(guac_socket* socket, const void* buf, size_t count) { @@ -150,9 +118,6 @@ guac_socket* guac_socket_alloc() { socket->state = GUAC_SOCKET_OPEN; socket->last_write_timestamp = guac_timestamp_current(); - /* No keep alive ping by default */ - socket->__keep_alive_enabled = 0; - /* No handlers yet */ socket->read_handler = NULL; socket->write_handler = NULL; @@ -166,15 +131,6 @@ guac_socket* guac_socket_alloc() { } -void guac_socket_require_keep_alive(guac_socket* socket) { - - /* Start keep-alive thread */ - socket->__keep_alive_enabled = 1; - pthread_create(&(socket->__keep_alive_thread), NULL, - __guac_socket_keep_alive_thread, (void*) socket); - -} - void guac_socket_instruction_begin(guac_socket* socket) { /* Call instruction begin handler if defined */ @@ -202,10 +158,6 @@ void guac_socket_free(guac_socket* socket) { /* Mark as closed */ socket->state = GUAC_SOCKET_CLOSED; - /* Wait for keep-alive, if enabled */ - if (socket->__keep_alive_enabled) - pthread_join(socket->__keep_alive_thread, NULL); - free(socket); } diff --git a/guacamole/src/protocols/vnc/vnc.c b/guacamole/src/protocols/vnc/vnc.c index 24e1534..a614604 100644 --- a/guacamole/src/protocols/vnc/vnc.c +++ b/guacamole/src/protocols/vnc/vnc.c @@ -164,9 +164,6 @@ void* guac_vnc_client_thread(void* data) { "clipboard encoding: '%s'.", settings->clipboard_encoding); } - /* Ensure connection is kept alive during lengthy connects */ - guac_socket_require_keep_alive(client->socket); - /* Set up libvncclient logging */ rfbClientLog = guac_vnc_client_log_info; rfbClientErr = guac_vnc_client_log_error;