]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/ping/PingerDaemon.java
fix: ssl-pinging stabelize + timeout
[gigi.git] / src / org / cacert / gigi / ping / PingerDaemon.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();
             }
         }
     }