summaryrefslogtreecommitdiff
path: root/data/libvncserver/clsockrace.diff
blob: 56b41e38e2e4284cb6fd90b9c28e7d75b4167142 (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 -ru LibVNCServer-0.9.8.1/libvncserver/main.c LibVNCServer-0.9.8.1+iPhone/libvncserver/main.c
--- LibVNCServer-0.9.8.1/libvncserver/main.c	2011-10-12 16:52:18.000000000 +0000
+++ LibVNCServer-0.9.8.1+iPhone/libvncserver/main.c	2011-10-13 04:09:56.000000000 +0000
@@ -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))
             rfbProcessClientMessage(cl);
     }