summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2011-08-16 14:02:32 +0200
committerJohannes Schindelin <johannes.schindelin@gmx.de>2011-08-17 12:41:24 +0200
commit0860c4951fd1b6d90158c35ead4a4c33635802bb (patch)
treefaae1fc5873ef8beeeddff214007d1f5ea3266a5
parent6fac22a74b5020387a6961e4cc197b5fa4743f96 (diff)
downloadlibtdevnc-0860c495.tar.gz
libtdevnc-0860c495.zip
websockets: Better disconnect detection.
If the only thing we are waiting on is a WebSockets terminator, then remove it from the stream early on in rfbProcessClientNormalMessage. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
-rw-r--r--libvncserver/rfbserver.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/libvncserver/rfbserver.c b/libvncserver/rfbserver.c
index 1df4fee..491a438 100644
--- a/libvncserver/rfbserver.c
+++ b/libvncserver/rfbserver.c
@@ -1844,6 +1844,11 @@ rfbProcessClientNormalMessage(rfbClientPtr cl)
/* With Base64 encoding we need at least 4 bytes */
n = recv(cl->sock, encBuf, 4, MSG_PEEK);
if ((n > 0) && (n < 4)) {
+ if (encBuf[0] == '\xff') {
+ /* Make sure we don't miss a client disconnect on an end frame
+ * marker */
+ n = read(cl->sock, encBuf, 1);
+ }
return;
}
}