diff options
author | dscho <dscho> | 2006-03-01 11:52:04 +0000 |
---|---|---|
committer | dscho <dscho> | 2006-03-01 11:52:04 +0000 |
commit | 4130598960e8f92341fdbf14dc315c60ca6ef1cf (patch) | |
tree | 00e2561b7f07ef3c25d8ee48ef1a4645a4f5e8c9 /libvncserver | |
parent | 3c2ea8d05af99846f23d0f9877ed016e83b64c49 (diff) | |
download | libtdevnc-4130598960e8f92341fdbf14dc315c60ca6ef1cf.tar.gz libtdevnc-4130598960e8f92341fdbf14dc315c60ca6ef1cf.zip |
do not timeout on idle client input (with pthreads)
Diffstat (limited to 'libvncserver')
-rw-r--r-- | libvncserver/main.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/libvncserver/main.c b/libvncserver/main.c index 093f81d..c618280 100644 --- a/libvncserver/main.c +++ b/libvncserver/main.c @@ -491,6 +491,21 @@ clientInput(void *data) pthread_create(&output_thread, NULL, clientOutput, (void *)cl); 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); if (cl->sock == -1) { /* Client has disconnected. */ @@ -521,6 +536,7 @@ listenerRun(void *data) len = sizeof(peer); /* TODO: this thread wont die by restarting the server */ + /* TODO: HTTP is not handled */ while ((client_fd = accept(screen->listenSock, (struct sockaddr*)&peer, &len)) >= 0) { cl = rfbNewClient(screen,client_fd); |