GUACAMOLE-118: Use poll() when waiting for data from SSH.
This commit is contained in:
parent
168359344e
commit
2421fc2f11
@ -44,13 +44,13 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
#include <poll.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/select.h>
|
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
@ -362,19 +362,18 @@ void* ssh_client_thread(void* data) {
|
|||||||
|
|
||||||
/* Wait for more data if reads turn up empty */
|
/* Wait for more data if reads turn up empty */
|
||||||
if (total_read == 0) {
|
if (total_read == 0) {
|
||||||
fd_set fds;
|
|
||||||
struct timeval timeout;
|
|
||||||
|
|
||||||
FD_ZERO(&fds);
|
/* Wait on the SSH session file descriptor only */
|
||||||
FD_SET(ssh_client->session->fd, &fds);
|
struct pollfd fds[] = {{
|
||||||
|
.fd = ssh_client->session->fd,
|
||||||
|
.events = POLLIN,
|
||||||
|
.revents = 0,
|
||||||
|
}};
|
||||||
|
|
||||||
/* Wait for one second */
|
/* Wait up to one second */
|
||||||
timeout.tv_sec = 1;
|
if (poll(fds, 1, 1000) < 0)
|
||||||
timeout.tv_usec = 0;
|
|
||||||
|
|
||||||
if (select(ssh_client->session->fd + 1, &fds,
|
|
||||||
NULL, NULL, &timeout) < 0)
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user