Use input/output threads for SSH client.
This commit is contained in:
parent
96edfad7c0
commit
8f0c2f3723
@ -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;
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user