GUACAMOLE-221: Sockets start keep alive by default.

This commit is contained in:
Nick Couchman 2020-06-27 22:43:25 -04:00
parent c579e7337f
commit 0761908a77
6 changed files with 12 additions and 16 deletions

View File

@ -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. * to ensure neither side of the socket times out while the socket is open.
* This ping will take the form of a "nop" instruction. * 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 * @param socket
* The guac_socket to declare as requiring an automatic keep-alive ping. * The guac_socket to declare as requiring an automatic keep-alive ping.
*/ */

View File

@ -150,8 +150,10 @@ guac_socket* guac_socket_alloc() {
socket->state = GUAC_SOCKET_OPEN; socket->state = GUAC_SOCKET_OPEN;
socket->last_write_timestamp = guac_timestamp_current(); socket->last_write_timestamp = guac_timestamp_current();
/* No keep alive ping by default */ /* keep alive ping by default */
socket->__keep_alive_enabled = 0; socket->__keep_alive_enabled = 1;
pthread_create(&(socket->__keep_alive_thread), NULL,
__guac_socket_keep_alive_thread, (void*) socket);
/* No handlers yet */ /* No handlers yet */
socket->read_handler = NULL; socket->read_handler = NULL;

View File

@ -257,8 +257,7 @@ static BOOL rdp_freerdp_authenticate(freerdp* instance, char** username,
/* Lock the client thread. */ /* Lock the client thread. */
pthread_mutex_lock(&(rdp_client->rdp_credential_lock)); pthread_mutex_lock(&(rdp_client->rdp_credential_lock));
/* Send require params and flush socket. */ /* Send require parameters to the owner. */
guac_socket_require_keep_alive(client->socket);
guac_client_owner_send_required(client, (const char**) params); guac_client_owner_send_required(client, (const char**) params);
/* Wait for condition. */ /* Wait for condition. */

View File

@ -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. */ /* Lock the terminal thread while prompting for the credential. */
pthread_mutex_lock(&(ssh_client->term_channel_lock)); pthread_mutex_lock(&(ssh_client->term_channel_lock));
/* Let the owner know what we require and flush the socket. */ /* Let the owner know what we require. */
guac_socket_require_keep_alive(client->socket);
guac_client_owner_send_required(client, (const char* []) {cred_name, NULL}); guac_client_owner_send_required(client, (const char* []) {cred_name, NULL});
/* Wait for the response, and then unlock the thread. */ /* Wait for the response, and then unlock the thread. */
@ -272,9 +271,6 @@ void* ssh_client_thread(void* data) {
return NULL; return NULL;
} }
/* Ensure connection is kept alive during lengthy connects */
guac_socket_require_keep_alive(client->socket);
/* Open SSH session */ /* Open SSH session */
ssh_client->session = guac_common_ssh_create_session(client, ssh_client->session = guac_common_ssh_create_session(client,
settings->hostname, settings->port, ssh_client->user, settings->server_alive_interval, settings->hostname, settings->port, ssh_client->user, settings->server_alive_interval,

View File

@ -41,8 +41,7 @@ char* guac_vnc_get_password(rfbClient* client) {
/* Lock the thread. */ /* Lock the thread. */
pthread_mutex_lock(&(vnc_client->vnc_credential_lock)); pthread_mutex_lock(&(vnc_client->vnc_credential_lock));
/* Send the request for password and flush the socket. */ /* Send the request for password to the owner. */
guac_socket_require_keep_alive(gc->socket);
guac_client_owner_send_required(gc, guac_client_owner_send_required(gc,
(const char* []) {GUAC_VNC_PARAMETER_NAME_PASSWORD, NULL}); (const char* []) {GUAC_VNC_PARAMETER_NAME_PASSWORD, NULL});
@ -91,8 +90,7 @@ rfbCredential* guac_vnc_get_credentials(rfbClient* client, int credentialType) {
/* Lock the thread. */ /* Lock the thread. */
pthread_mutex_lock(&(vnc_client->vnc_credential_lock)); pthread_mutex_lock(&(vnc_client->vnc_credential_lock));
/* Send required parameters to client and flush the socket. */ /* Send required parameters to owner. */
guac_socket_require_keep_alive(gc->socket);
guac_client_owner_send_required(gc, (const char**) params); guac_client_owner_send_required(gc, (const char**) params);
/* Wait for the parameters to be returned. */ /* Wait for the parameters to be returned. */

View File

@ -259,9 +259,6 @@ void* guac_vnc_client_thread(void* data) {
"clipboard encoding: '%s'.", settings->clipboard_encoding); "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 */ /* Set up libvncclient logging */
rfbClientLog = guac_vnc_client_log_info; rfbClientLog = guac_vnc_client_log_info;
rfbClientErr = guac_vnc_client_log_error; rfbClientErr = guac_vnc_client_log_error;