Author: toad
Date: 2008-02-16 18:55:17 +0000 (Sat, 16 Feb 2008)
New Revision: 18008

Modified:
   trunk/freenet/src/freenet/io/comm/UdpSocketHandler.java
Log:
Check for _isDone = true and _active = true in USMChecker.

Modified: trunk/freenet/src/freenet/io/comm/UdpSocketHandler.java
===================================================================
--- trunk/freenet/src/freenet/io/comm/UdpSocketHandler.java     2008-02-16 
18:41:06 UTC (rev 18007)
+++ trunk/freenet/src/freenet/io/comm/UdpSocketHandler.java     2008-02-16 
18:55:17 UTC (rev 18008)
@@ -310,7 +310,24 @@
                public void run() {
                    freenet.support.Logger.OSThread.logPID(this);
                        while(true) {
-                               if(_isDone) return; // don't synchronize 
because don't want to deadlock - this is our recovery mechanism
+                               if(_isDone) {
+                                       boolean active;
+                                       // Gone now, so we can safely 
synchronize.
+                                       synchronized(this) {
+                                               active = _active;
+                                       }
+                                       if(active) {
+                                               
System.err.println("UdpSocketHandler for port "+listenPort+" has died without 
being told to! Restarting node...");
+                                               if(node.isUsingWrapper()){
+                                                       
WrapperManager.requestThreadDump();
+                                                       
WrapperManager.restart();
+                                               }else{
+                                                       // No wrapper : we 
don't want to let it harm the network!
+                                                       node.exit("USM 
deadlock");
+                                               }
+                                       }
+                                       return; // don't synchronize because 
don't want to deadlock - this is our recovery mechanism
+                               }
                                logMINOR = Logger.shouldLog(Logger.MINOR, 
UdpSocketHandler.this);
                                try {
                                        Thread.sleep(10*1000);


Reply via email to