diff --git a/src/libguac/guacamole/socket.h b/src/libguac/guacamole/socket.h index 2da697fe..cce4f69e 100644 --- a/src/libguac/guacamole/socket.h +++ b/src/libguac/guacamole/socket.h @@ -136,6 +136,10 @@ void guac_socket_free(guac_socket* socket); * to ensure neither side of the socket times out while the socket is open. * This ping will take the form of a "nop" instruction. * + * @deprecated + * Manually starting the keep alive process on sockets is no longer + * necessary, as the sockets enable the "nop" ping by default. + * * @param socket * The guac_socket to declare as requiring an automatic keep-alive ping. */ diff --git a/src/libguac/socket.c b/src/libguac/socket.c index 66442d0c..8892256e 100644 --- a/src/libguac/socket.c +++ b/src/libguac/socket.c @@ -150,8 +150,10 @@ 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; + /* keep alive ping by default */ + socket->__keep_alive_enabled = 1; + pthread_create(&(socket->__keep_alive_thread), NULL, + __guac_socket_keep_alive_thread, (void*) socket); /* No handlers yet */ socket->read_handler = NULL; diff --git a/src/protocols/rdp/rdp.c b/src/protocols/rdp/rdp.c index 9c064c70..c4bfc28b 100644 --- a/src/protocols/rdp/rdp.c +++ b/src/protocols/rdp/rdp.c @@ -257,8 +257,7 @@ static BOOL rdp_freerdp_authenticate(freerdp* instance, char** username, /* Lock the client thread. */ pthread_mutex_lock(&(rdp_client->rdp_credential_lock)); - /* Send require params and flush socket. */ - guac_socket_require_keep_alive(client->socket); + /* Send require parameters to the owner. */ guac_client_owner_send_required(client, (const char**) params); /* Wait for condition. */ diff --git a/src/protocols/ssh/ssh.c b/src/protocols/ssh/ssh.c index 23fbee0d..9c87380f 100644 --- a/src/protocols/ssh/ssh.c +++ b/src/protocols/ssh/ssh.c @@ -77,8 +77,7 @@ static void guac_ssh_get_credential(guac_client *client, char* cred_name) { /* Lock the terminal thread while prompting for the credential. */ pthread_mutex_lock(&(ssh_client->term_channel_lock)); - /* Let the owner know what we require and flush the socket. */ - guac_socket_require_keep_alive(client->socket); + /* Let the owner know what we require. */ guac_client_owner_send_required(client, (const char* []) {cred_name, NULL}); /* Wait for the response, and then unlock the thread. */ @@ -272,9 +271,6 @@ void* ssh_client_thread(void* data) { return NULL; } - /* Ensure connection is kept alive during lengthy connects */ - guac_socket_require_keep_alive(client->socket); - /* Open SSH session */ ssh_client->session = guac_common_ssh_create_session(client, settings->hostname, settings->port, ssh_client->user, settings->server_alive_interval, diff --git a/src/protocols/vnc/auth.c b/src/protocols/vnc/auth.c index 434e1c0a..fc534573 100644 --- a/src/protocols/vnc/auth.c +++ b/src/protocols/vnc/auth.c @@ -41,8 +41,7 @@ char* guac_vnc_get_password(rfbClient* client) { /* Lock the thread. */ pthread_mutex_lock(&(vnc_client->vnc_credential_lock)); - /* Send the request for password and flush the socket. */ - guac_socket_require_keep_alive(gc->socket); + /* Send the request for password to the owner. */ guac_client_owner_send_required(gc, (const char* []) {GUAC_VNC_PARAMETER_NAME_PASSWORD, NULL}); @@ -91,8 +90,7 @@ rfbCredential* guac_vnc_get_credentials(rfbClient* client, int credentialType) { /* Lock the thread. */ pthread_mutex_lock(&(vnc_client->vnc_credential_lock)); - /* Send required parameters to client and flush the socket. */ - guac_socket_require_keep_alive(gc->socket); + /* Send required parameters to owner. */ guac_client_owner_send_required(gc, (const char**) params); /* Wait for the parameters to be returned. */ diff --git a/src/protocols/vnc/vnc.c b/src/protocols/vnc/vnc.c index 31d97022..33bd5c59 100644 --- a/src/protocols/vnc/vnc.c +++ b/src/protocols/vnc/vnc.c @@ -259,9 +259,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;