]> source.dussan.org Git - tigervnc.git/commitdiff
Set explicit connect timeout on socket and use timer instead of counting iterations
authorBrian P. Hinz <bphinz@users.sf.net>
Thu, 7 Nov 2019 00:24:16 +0000 (19:24 -0500)
committerBrian P. Hinz <bphinz@users.sf.net>
Thu, 7 Nov 2019 00:26:53 +0000 (19:26 -0500)
java/com/tigervnc/vncviewer/Tunnel.java

index 2d0c61f5bc19324ae820d24fd67f2a27b2a43fa1..ef5be2794ae9dc6f122321029b66740009b33481 100644 (file)
@@ -212,7 +212,8 @@ public class Tunnel {
       Thread t = new Thread(new ExtProcess(cmd, vlog, true));
       t.start();
       // try for up to 5s
-      for (int i=0;i<50;i++) {
+      long start = System.currentTimeMillis();
+      while (System.currentTimeMillis() - start < 5000) {
         if (isTunnelReady(localPort))
           return;
         else
@@ -232,7 +233,7 @@ public class Tunnel {
       java.net.Socket socket = new java.net.Socket();
       boolean ready = false;
       try {
-        socket.connect(sockAddr);
+        socket.connect(sockAddr, 1000);
         ready = socket.isConnected();
         socket.close();
       } catch (IOException e) {