]> WPIA git - gigi.git/commitdiff
fix: ssl-pinging stabelize + timeout
authorFelix Dörre <felix@dogcraft.de>
Tue, 15 Sep 2015 21:03:38 +0000 (23:03 +0200)
committerFelix Dörre <felix@dogcraft.de>
Tue, 15 Sep 2015 21:03:38 +0000 (23:03 +0200)
src/org/cacert/gigi/ping/PingerDaemon.java
src/org/cacert/gigi/ping/SSLPinger.java

index e543ca1cd4dd60ed41f922aa11edf451f2ad7de7..deb5215adda8b1391ab5772921a2cee5951c71e0 100644 (file)
@@ -39,22 +39,31 @@ public class PingerDaemon extends Thread {
         pingers.put(PingType.DNS, new DNSPinger());
 
         while (true) {
-            synchronized (this) {
-                DomainPingConfiguration conf;
-                while ((conf = toExecute.peek()) != null) {
-                    handle(conf);
-                    toExecute.remove();
+            try {
+                boolean worked = false;
+                synchronized (this) {
+                    DomainPingConfiguration conf;
+                    while ((conf = toExecute.peek()) != null) {
+                        worked = true;
+                        handle(conf);
+                        toExecute.remove();
+                    }
+                    notifyAll();
                 }
-                notifyAll();
-            }
 
-            GigiResultSet rs = searchNeededPings.executeQuery();
-            while (rs.next()) {
-                handle(DomainPingConfiguration.getById(rs.getInt("id")));
-            }
-            try {
-                Thread.sleep(5000);
-            } catch (InterruptedException e) {
+                GigiResultSet rs = searchNeededPings.executeQuery();
+                while (rs.next()) {
+                    worked = true;
+                    handle(DomainPingConfiguration.getById(rs.getInt("id")));
+                }
+                try {
+                    if ( !worked) {
+                        Thread.sleep(5000);
+                    }
+                } catch (InterruptedException e) {
+                }
+            } catch (Throwable t) {
+                t.printStackTrace();
             }
         }
     }
index 85189e9c05beed6e8cbf33d89afd9ef1917fd0da..962d874b1c5c2b45b93de31a22791e60ddc0aa46 100644 (file)
@@ -147,6 +147,7 @@ public class SSLPinger extends DomainPinger {
 
     private String test(SocketChannel sch, String domain, User subject) {
         try {
+            sch.socket().setSoTimeout(5000);
             SSLContext sc = SSLContext.getInstance("SSL");
             try {
                 TrustManagerFactory tmf = TrustManagerFactory.getInstance("X509");