|
|
@ -33,6 +33,7 @@
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#include <signal.h>
|
|
|
|
#include <signal.h>
|
|
|
@ -533,6 +534,7 @@ clientInput(void *data)
|
|
|
|
|
|
|
|
|
|
|
|
FD_ZERO(&rfds);
|
|
|
|
FD_ZERO(&rfds);
|
|
|
|
FD_SET(cl->sock, &rfds);
|
|
|
|
FD_SET(cl->sock, &rfds);
|
|
|
|
|
|
|
|
FD_SET(cl->pipe_notify_client_thread[0], &rfds);
|
|
|
|
FD_ZERO(&efds);
|
|
|
|
FD_ZERO(&efds);
|
|
|
|
FD_SET(cl->sock, &efds);
|
|
|
|
FD_SET(cl->sock, &efds);
|
|
|
|
|
|
|
|
|
|
|
@ -541,9 +543,13 @@ clientInput(void *data)
|
|
|
|
if ((cl->fileTransfer.fd!=-1) && (cl->fileTransfer.sending==1))
|
|
|
|
if ((cl->fileTransfer.fd!=-1) && (cl->fileTransfer.sending==1))
|
|
|
|
FD_SET(cl->sock, &wfds);
|
|
|
|
FD_SET(cl->sock, &wfds);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int nfds = cl->pipe_notify_client_thread[0] > cl->sock ? cl->pipe_notify_client_thread[0] : cl->sock;
|
|
|
|
|
|
|
|
|
|
|
|
tv.tv_sec = 60; /* 1 minute */
|
|
|
|
tv.tv_sec = 60; /* 1 minute */
|
|
|
|
tv.tv_usec = 0;
|
|
|
|
tv.tv_usec = 0;
|
|
|
|
n = select(cl->sock + 1, &rfds, &wfds, &efds, &tv);
|
|
|
|
|
|
|
|
|
|
|
|
n = select(nfds + 1, &rfds, &wfds, &efds, &tv);
|
|
|
|
|
|
|
|
|
|
|
|
if (n < 0) {
|
|
|
|
if (n < 0) {
|
|
|
|
rfbLogPerror("ReadExact: select");
|
|
|
|
rfbLogPerror("ReadExact: select");
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -558,6 +564,13 @@ clientInput(void *data)
|
|
|
|
if (FD_ISSET(cl->sock, &wfds))
|
|
|
|
if (FD_ISSET(cl->sock, &wfds))
|
|
|
|
rfbSendFileTransferChunk(cl);
|
|
|
|
rfbSendFileTransferChunk(cl);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (FD_ISSET(cl->pipe_notify_client_thread[0], &rfds))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// Reset the pipe
|
|
|
|
|
|
|
|
char buf;
|
|
|
|
|
|
|
|
while (read(cl->pipe_notify_client_thread[0], &buf, sizeof(buf)) == sizeof(buf));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (FD_ISSET(cl->sock, &rfds) || FD_ISSET(cl->sock, &efds))
|
|
|
|
if (FD_ISSET(cl->sock, &rfds) || FD_ISSET(cl->sock, &efds))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#ifdef LIBVNCSERVER_WITH_WEBSOCKETS
|
|
|
|
#ifdef LIBVNCSERVER_WITH_WEBSOCKETS
|
|
|
@ -628,8 +641,12 @@ rfbStartOnHoldClient(rfbClientPtr cl)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
cl->onHold = FALSE;
|
|
|
|
cl->onHold = FALSE;
|
|
|
|
#ifdef LIBVNCSERVER_HAVE_LIBPTHREAD
|
|
|
|
#ifdef LIBVNCSERVER_HAVE_LIBPTHREAD
|
|
|
|
if(cl->screen->backgroundLoop)
|
|
|
|
if(cl->screen->backgroundLoop) {
|
|
|
|
pthread_create(&cl->client_thread, NULL, clientInput, (void *)cl);
|
|
|
|
pipe(cl->pipe_notify_client_thread);
|
|
|
|
|
|
|
|
fcntl(cl->pipe_notify_client_thread[0], F_SETFL, O_NONBLOCK);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pthread_create(&cl->client_thread, NULL, clientInput, (void *)cl);
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1091,7 +1108,13 @@ void rfbShutdownServer(rfbScreenInfoPtr screen,rfbBool disconnectClients) {
|
|
|
|
rfbCloseClient(currentCl);
|
|
|
|
rfbCloseClient(currentCl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef LIBVNCSERVER_HAVE_LIBPTHREAD
|
|
|
|
|
|
|
|
// Notify the thread and join it
|
|
|
|
|
|
|
|
write(currentCl->pipe_notify_client_thread[1], "\x00", 1);
|
|
|
|
|
|
|
|
pthread_join(currentCl->client_thread, NULL);
|
|
|
|
|
|
|
|
#else
|
|
|
|
rfbClientConnectionGone(currentCl);
|
|
|
|
rfbClientConnectionGone(currentCl);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
currentCl = nextCl;
|
|
|
|
currentCl = nextCl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|