Using ssh_select (works) instead of channel_select (doesn't work).
This commit is contained in:
parent
f695f5c629
commit
15ae8d79a2
@ -35,6 +35,8 @@
|
|||||||
*
|
*
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
#include <sys/select.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@ -57,26 +59,32 @@ int ssh_guac_client_handle_messages(guac_client* client) {
|
|||||||
ssh_guac_client_data* client_data = (ssh_guac_client_data*) client->data;
|
ssh_guac_client_data* client_data = (ssh_guac_client_data*) client->data;
|
||||||
char buffer[8192];
|
char buffer[8192];
|
||||||
|
|
||||||
ssh_channel read_channels[2];
|
ssh_channel channels[2], out_channels[2];
|
||||||
struct timeval timeout;
|
struct timeval timeout;
|
||||||
|
fd_set fds;
|
||||||
guac_log_info("ENTER HANDLE MESSAGES...");
|
int ssh_fd;
|
||||||
|
|
||||||
/* Channels to read */
|
/* Channels to read */
|
||||||
read_channels[0] = client_data->term_channel;
|
channels[0] = client_data->term_channel;
|
||||||
read_channels[1] = NULL;
|
channels[1] = NULL;
|
||||||
|
|
||||||
|
/* Get SSH file descriptor */
|
||||||
|
ssh_fd = ssh_get_fd(client_data->session);
|
||||||
|
|
||||||
|
/* Build fd_set */
|
||||||
|
FD_ZERO(&fds);
|
||||||
|
FD_SET(ssh_fd, &fds);
|
||||||
|
|
||||||
/* Time to wait */
|
/* Time to wait */
|
||||||
timeout.tv_sec = GUAC_SYNC_FREQUENCY / 1000;
|
timeout.tv_sec = GUAC_SYNC_FREQUENCY / 1000;
|
||||||
timeout.tv_usec = (GUAC_SYNC_FREQUENCY % 1000) * 1000;
|
timeout.tv_usec = (GUAC_SYNC_FREQUENCY % 1000) * 1000;
|
||||||
|
|
||||||
/* Wait for data to be available */
|
/* Wait for data to be available */
|
||||||
if (channel_select(read_channels, NULL, NULL, &timeout) == SSH_OK) {
|
if (ssh_select(channels, out_channels, ssh_fd+1, &fds, &timeout)
|
||||||
|
== SSH_OK) {
|
||||||
|
|
||||||
int bytes_read = 0;
|
int bytes_read = 0;
|
||||||
|
|
||||||
guac_log_info("DONE WAITING (%i)", GUAC_SYNC_FREQUENCY);
|
|
||||||
|
|
||||||
/* While data available, write to terminal */
|
/* While data available, write to terminal */
|
||||||
while (channel_is_open(client_data->term_channel)
|
while (channel_is_open(client_data->term_channel)
|
||||||
&& !channel_is_eof(client_data->term_channel)
|
&& !channel_is_eof(client_data->term_channel)
|
||||||
@ -97,7 +105,6 @@ int ssh_guac_client_handle_messages(guac_client* client) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
guac_log_info("LEAVE HANDLE MESSAGES");
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user