summaryrefslogtreecommitdiff
path: root/data/libvncserver/clsockrace.diff
blob: 9b1f2ad5d39646f307d953f69bd218fa8c2e4a26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
diff -ur libvncserver-LibVNCServer-0.9.11/libvncserver/main.c libvncserver-LibVNCServer-0.9.11+iPhone/libvncserver/main.c
--- libvncserver-LibVNCServer-0.9.11/libvncserver/main.c	2016-12-30 03:01:28.000000000 -1000
+++ libvncserver-LibVNCServer-0.9.11+iPhone/libvncserver/main.c	2018-08-29 11:20:52.000000000 -1000
@@ -517,24 +517,26 @@
 	struct timeval tv;
 	int n;
 
-	if (cl->sock == -1) {
+	int sock = cl->sock;
+
+	if (sock == -1) {
 	  /* Client has disconnected. */
             break;
         }
 
 	FD_ZERO(&rfds);
-	FD_SET(cl->sock, &rfds);
+	FD_SET(sock, &rfds);
 	FD_ZERO(&efds);
-	FD_SET(cl->sock, &efds);
+	FD_SET(sock, &efds);
 
 	/* Are we transferring a file in the background? */
 	FD_ZERO(&wfds);
 	if ((cl->fileTransfer.fd!=-1) && (cl->fileTransfer.sending==1))
-	    FD_SET(cl->sock, &wfds);
+	    FD_SET(sock, &wfds);
 
 	tv.tv_sec = 60; /* 1 minute */
 	tv.tv_usec = 0;
-	n = select(cl->sock + 1, &rfds, &wfds, &efds, &tv);
+	n = select(sock + 1, &rfds, &wfds, &efds, &tv);
 	if (n < 0) {
 	    rfbLogPerror("ReadExact: select");
 	    break;
@@ -546,10 +548,10 @@
         }
         
         /* We have some space on the transmit queue, send some data */
-        if (FD_ISSET(cl->sock, &wfds))
+        if (FD_ISSET(sock, &wfds))
             rfbSendFileTransferChunk(cl);
 
-        if (FD_ISSET(cl->sock, &rfds) || FD_ISSET(cl->sock, &efds))
+        if (FD_ISSET(sock, &rfds) || FD_ISSET(cl->sock, &efds))
         {
 #ifdef LIBVNCSERVER_WITH_WEBSOCKETS
             do {