Commit 41305989 authored by dscho's avatar dscho

do not timeout on idle client input (with pthreads)

parent 3c2ea8d0
...@@ -491,6 +491,21 @@ clientInput(void *data) ...@@ -491,6 +491,21 @@ clientInput(void *data)
pthread_create(&output_thread, NULL, clientOutput, (void *)cl); pthread_create(&output_thread, NULL, clientOutput, (void *)cl);
while (1) { while (1) {
fd_set fds;
struct timeval tv;
int n;
FD_ZERO(&fds);
FD_SET(cl->sock, &fds);
tv.tv_sec = 60; /* 1 minute */
tv.tv_usec = 0;
n = select(cl->sock + 1, &fds, NULL, &fds, &tv);
if (n < 0) {
rfbLogPerror("ReadExact: select");
break;
}
if (n == 0) /* timeout */
continue;
rfbProcessClientMessage(cl); rfbProcessClientMessage(cl);
if (cl->sock == -1) { if (cl->sock == -1) {
/* Client has disconnected. */ /* Client has disconnected. */
...@@ -521,6 +536,7 @@ listenerRun(void *data) ...@@ -521,6 +536,7 @@ listenerRun(void *data)
len = sizeof(peer); len = sizeof(peer);
/* TODO: this thread wont die by restarting the server */ /* TODO: this thread wont die by restarting the server */
/* TODO: HTTP is not handled */
while ((client_fd = accept(screen->listenSock, while ((client_fd = accept(screen->listenSock,
(struct sockaddr*)&peer, &len)) >= 0) { (struct sockaddr*)&peer, &len)) >= 0) {
cl = rfbNewClient(screen,client_fd); cl = rfbNewClient(screen,client_fd);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment