summaryrefslogtreecommitdiffstats
path: root/libvncserver/httpd.c
diff options
context:
space:
mode:
authorChristian Beier <dontmind@freeshell.org>2010-09-07 17:43:58 +0200
committerChristian Beier <dontmind@freeshell.org>2010-09-13 14:19:15 +0200
commitc0373e9cd48b0fc22ac295fdab51a29e3df7a0cd (patch)
tree253b193dfb1805cd6de337f26cf6f82e74a42cad /libvncserver/httpd.c
parent0df84e5c27eefad8b731b12d58f8fbede71823e0 (diff)
downloadlibtdevnc-c0373e9cd48b0fc22ac295fdab51a29e3df7a0cd.tar.gz
libtdevnc-c0373e9cd48b0fc22ac295fdab51a29e3df7a0cd.zip
Non-blocking sockets for Windows.
Expands the SetNonBlocking() function in libvncclient/sockets.c to also work under Windows and also changes it to honour maybe already present socket flags. A similar function was introduced for libvncserver as well and all the #ifdef'ed fnctl calls replaced with calls to that one. Signed-off-by: Christian Beier <dontmind@freeshell.org>
Diffstat (limited to 'libvncserver/httpd.c')
-rwxr-xr-xlibvncserver/httpd.c25
1 files changed, 5 insertions, 20 deletions
diff --git a/libvncserver/httpd.c b/libvncserver/httpd.c
index c183543..320e6d2 100755
--- a/libvncserver/httpd.c
+++ b/libvncserver/httpd.c
@@ -181,7 +181,6 @@ rfbHttpCheckFds(rfbScreenInfoPtr rfbScreen)
}
if (FD_ISSET(rfbScreen->httpListenSock, &fds)) {
- int flags;
if (rfbScreen->httpSock >= 0) close(rfbScreen->httpSock);
if ((rfbScreen->httpSock = accept(rfbScreen->httpListenSock,
@@ -189,35 +188,21 @@ rfbHttpCheckFds(rfbScreenInfoPtr rfbScreen)
rfbLogPerror("httpCheckFds: accept");
return;
}
-#ifdef __MINGW32__
- rfbErr("O_NONBLOCK on MinGW32 NOT IMPLEMENTED");
-#else
#ifdef USE_LIBWRAP
if(!hosts_ctl("vnc",STRING_UNKNOWN,inet_ntoa(addr.sin_addr),
STRING_UNKNOWN)) {
rfbLog("Rejected HTTP connection from client %s\n",
inet_ntoa(addr.sin_addr));
-#else
- flags = fcntl(rfbScreen->httpSock, F_GETFL);
-
- if (flags < 0 || fcntl(rfbScreen->httpSock, F_SETFL, flags | O_NONBLOCK) == -1) {
- rfbLogPerror("httpCheckFds: fcntl");
-#endif
- close(rfbScreen->httpSock);
- rfbScreen->httpSock = -1;
- return;
- }
-
- flags=fcntl(rfbScreen->httpSock,F_GETFL);
- if(flags==-1 ||
- fcntl(rfbScreen->httpSock,F_SETFL,flags|O_NONBLOCK)==-1) {
- rfbLogPerror("httpCheckFds: fcntl");
close(rfbScreen->httpSock);
rfbScreen->httpSock=-1;
return;
}
#endif
-
+ if(!rfbSetNonBlocking(rfbScreen->httpSock)) {
+ close(rfbScreen->httpSock);
+ rfbScreen->httpSock=-1;
+ return;
+ }
/*AddEnabledDevice(httpSock);*/
}
}