int guac_telnet_client_free_handler(guac_client* client) { guac_telnet_client* telnet_client = (guac_telnet_client*) client->data; /* Close telnet connection */ if (telnet_client->socket_fd != -1) close(telnet_client->socket_fd); /* Clean up recording, if in progress */ if (telnet_client->recording != NULL) guac_common_recording_free(telnet_client->recording); /* Kill terminal */ guac_terminal_free(telnet_client->term); /* Wait for and free telnet session, if connected */ if (telnet_client->telnet != NULL) { pthread_join(telnet_client->client_thread, NULL); telnet_free(telnet_client->telnet); } /* Free settings */ if (telnet_client->settings != NULL) guac_telnet_settings_free(telnet_client->settings); free(telnet_client); return 0; }
int guac_rdp_client_free_handler(guac_client* client) { guac_rdp_client* rdp_client = (guac_rdp_client*) client->data; /* Wait for client thread */ pthread_join(rdp_client->client_thread, NULL); /* Free parsed settings */ if (rdp_client->settings != NULL) guac_rdp_settings_free(rdp_client->settings); /* Free display update module */ guac_rdp_disp_free(rdp_client->disp); /* Clean up filesystem, if allocated */ if (rdp_client->filesystem != NULL) guac_rdp_fs_free(rdp_client->filesystem); #ifdef ENABLE_COMMON_SSH /* Free SFTP filesystem, if loaded */ if (rdp_client->sftp_filesystem) guac_common_ssh_destroy_sftp_filesystem(rdp_client->sftp_filesystem); /* Free SFTP session */ if (rdp_client->sftp_session) guac_common_ssh_destroy_session(rdp_client->sftp_session); /* Free SFTP user */ if (rdp_client->sftp_user) guac_common_ssh_destroy_user(rdp_client->sftp_user); guac_common_ssh_uninit(); #endif /* Clean up recording, if in progress */ if (rdp_client->recording != NULL) guac_common_recording_free(rdp_client->recording); /* Clean up audio stream, if allocated */ if (rdp_client->audio != NULL) guac_audio_stream_free(rdp_client->audio); /* Clean up audio input buffer, if allocated */ if (rdp_client->audio_input != NULL) guac_rdp_audio_buffer_free(rdp_client->audio_input); /* Free client data */ guac_common_clipboard_free(rdp_client->clipboard); free(rdp_client); return 0; }
int guac_vnc_client_free_handler(guac_client* client) { guac_vnc_client* vnc_client = (guac_vnc_client*) client->data; guac_vnc_settings* settings = vnc_client->settings; /* Clean up VNC client*/ rfbClient* rfb_client = vnc_client->rfb_client; if (rfb_client != NULL) { /* Wait for client thread to finish */ pthread_join(vnc_client->client_thread, NULL); /* Free memory not free'd by libvncclient's rfbClientCleanup() */ if (rfb_client->frameBuffer != NULL) free(rfb_client->frameBuffer); if (rfb_client->raw_buffer != NULL) free(rfb_client->raw_buffer); if (rfb_client->rcSource != NULL) free(rfb_client->rcSource); /* Free VNC rfbClientData linked list (not free'd by rfbClientCleanup()) */ while (rfb_client->clientData != NULL) { rfbClientData* next = rfb_client->clientData->next; free(rfb_client->clientData); rfb_client->clientData = next; } rfbClientCleanup(rfb_client); } #ifdef ENABLE_COMMON_SSH /* Free SFTP filesystem, if loaded */ if (vnc_client->sftp_filesystem) guac_common_ssh_destroy_sftp_filesystem(vnc_client->sftp_filesystem); /* Free SFTP session */ if (vnc_client->sftp_session) guac_common_ssh_destroy_session(vnc_client->sftp_session); /* Free SFTP user */ if (vnc_client->sftp_user) guac_common_ssh_destroy_user(vnc_client->sftp_user); guac_common_ssh_uninit(); #endif /* Clean up recording, if in progress */ if (vnc_client->recording != NULL) guac_common_recording_free(vnc_client->recording); /* Free clipboard */ if (vnc_client->clipboard != NULL) guac_common_clipboard_free(vnc_client->clipboard); /* Free display */ if (vnc_client->display != NULL) guac_common_display_free(vnc_client->display); #ifdef ENABLE_PULSE /* If audio enabled, stop streaming */ if (vnc_client->audio) guac_pa_stream_free(vnc_client->audio); #endif /* Free parsed settings */ if (settings != NULL) guac_vnc_settings_free(settings); #ifdef ENABLE_VNC_TLS_LOCKING /* Clean up TLS lock mutex. */ pthread_mutex_destroy(&(vnc_client->tls_lock)); #endif /* Free generic data struct */ free(client->data); return 0; }