Skip to content

Commit ad55927

Browse files
committed
libvncclient: ensure WaitForMessage() says 1 in case of buffered data
Previously, WaitForMessage() would only check the socket for new data using select(), even when ReadFromRFBServer had already buffered unprocessed data. This could cause unnecessary timeouts and delays in message processing.
1 parent f2a118f commit ad55927

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/libvncclient/sockets.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,12 @@ int WaitForMessage(rfbClient* client,unsigned int usecs)
862862
if (client->serverPort==-1)
863863
/* playing back vncrec file */
864864
return 1;
865-
865+
866+
/* Check if we have buffered data available */
867+
if (client->buffered > 0) {
868+
return 1;
869+
}
870+
866871
timeout.tv_sec=(usecs/1000000);
867872
timeout.tv_usec=(usecs%1000000);
868873

0 commit comments

Comments
 (0)