Use input/output threads for SSH client.

This commit is contained in:
Michael Jumper 2013-05-17 20:53:16 -07:00
parent 96edfad7c0
commit 8f0c2f3723
5 changed files with 32 additions and 7 deletions

View File

@ -50,7 +50,15 @@
*/ */
typedef struct ssh_guac_client_data { typedef struct ssh_guac_client_data {
pthread_t client_thread; /**
* SSH client output thread.
*/
pthread_t output_thread;
/**
* SSH client input thread.
*/
pthread_t input_thread;
ssh_session session; ssh_session session;
ssh_channel term_channel; ssh_channel term_channel;

View File

@ -43,7 +43,12 @@
/** /**
* Main SSH client thread, handling transfer of SSH output to STDOUT. * Main SSH client thread, handling transfer of SSH output to STDOUT.
*/ */
void* ssh_client_thread(void* data); void* ssh_client_output_thread(void* data);
/**
* Secondary SSH client thread, handling transfer of STDIN to SSH input.
*/
void* ssh_client_input_thread(void* data);
#endif #endif

View File

@ -126,9 +126,15 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
client->size_handler = ssh_guac_client_size_handler; client->size_handler = ssh_guac_client_size_handler;
client->free_handler = ssh_guac_client_free_handler; client->free_handler = ssh_guac_client_free_handler;
/* Start client thread */ /* Start client output thread */
if (pthread_create(&(client_data->client_thread), NULL, ssh_client_thread, (void*) client)) { if (pthread_create(&(client_data->output_thread), NULL, ssh_client_output_thread, (void*) client)) {
guac_client_log_error(client, "Unable to SSH client thread"); guac_client_log_error(client, "Unable to start SSH client output thread");
return -1;
}
/* Start client input thread */
if (pthread_create(&(client_data->input_thread), NULL, ssh_client_input_thread, (void*) client)) {
guac_client_log_error(client, "Unable to start SSH client input thread");
return -1; return -1;
} }

View File

@ -352,7 +352,8 @@ int ssh_guac_client_free_handler(guac_client* client) {
/* Close SSH client */ /* Close SSH client */
close(STDOUT_FILENO); close(STDOUT_FILENO);
close(STDIN_FILENO); close(STDIN_FILENO);
pthread_join(guac_client_data->client_thread, NULL); pthread_join(guac_client_data->output_thread, NULL);
pthread_join(guac_client_data->input_thread, NULL);
/* Free terminal */ /* Free terminal */
guac_terminal_free(guac_client_data->term); guac_terminal_free(guac_client_data->term);

View File

@ -42,7 +42,7 @@
#include "client.h" #include "client.h"
void* ssh_client_thread(void* data) { void* ssh_client_output_thread(void* data) {
/* STUB */ /* STUB */
printf("--- STUB! ---\n"); printf("--- STUB! ---\n");
@ -52,3 +52,8 @@ void* ssh_client_thread(void* data) {
} }
void* ssh_client_input_thread(void* data) {
/* STUB */
return NULL;
}