r26634 - in trunk/freenet/src/freenet: io/comm node

[email protected]
Newsgroups gmane.network.freenet.cvs
Message-ID <[email protected]>
Author: j16sdiz
Date: 2009-04-08 05:03:11 +0000 (Wed, 08 Apr 2009)
New Revision: 26634

Modified:
   trunk/freenet/src/freenet/io/comm/UdpSocketHandler.java
   trunk/freenet/src/freenet/node/Node.java
   trunk/freenet/src/freenet/node/NodeCrypto.java
   trunk/freenet/src/freenet/node/OpennetManager.java
Log:
Remove UDPSocket Halt Checker

This is a prerequisite for the "Reduce SocketTimeOutException"
patch, which reduce the number of Exception thrown.

The EvailJVM bug is long solved. This code path is running as max
priority every 10 seconds, causing sigifiance power consumsion.

Modified: trunk/freenet/src/freenet/io/comm/UdpSocketHandler.java
===================================================================
--- trunk/freenet/src/freenet/io/comm/UdpSocketHandler.java	2009-04-08 05:02:45 UTC (rev 26633)
+++ trunk/freenet/src/freenet/io/comm/UdpSocketHandler.java	2009-04-08 05:03:11 UTC (rev 26634)
@@ -9,15 +9,10 @@
 import java.net.SocketTimeoutException;
 import java.util.Random;
 
-import org.tanukisoftware.wrapper.WrapperManager;
-
 import freenet.io.AddressTracker;
 import freenet.io.comm.Peer.LocalAddressException;
-import freenet.node.LoggingConfigHandler;
 import freenet.node.Node;
-import freenet.node.NodeInitException;
 import freenet.node.PrioRunnable;
-import freenet.support.FileLoggerHook;
 import freenet.support.Logger;
 import freenet.support.OOMHandler;
 import freenet.support.io.NativeThread;
@@ -38,7 +33,6 @@
 	private final Node node;
 	private static boolean logMINOR; 
 	private static boolean logDEBUG;
-	private volatile int lastTimeInSeconds;
 	private boolean _isDone;
 	private boolean _active = true;
 	private final int listenPort;
@@ -145,7 +139,6 @@
 				if(!_active) return; // Finished
 			}
 			try {
-				lastTimeInSeconds = (int) (System.currentTimeMillis() / 1000);
 				realRun(packet);
             } catch (OutOfMemoryError e) {
 				OOMHandler.handleOOM(e);
@@ -295,101 +288,16 @@
     public int getPacketSendThreshold() {
     	return getMaxPacketSize() - 100;
     }
-    
-	public void start() {
-		start(false);
-	}
 	
-	public void start(boolean disableHangChecker) {
-		lastTimeInSeconds = (int) (System.currentTimeMillis() / 1000);
+	public void start() {
 		synchronized(this) {
 			if(!_active) return;
 			_started = true;
 			startTime = System.currentTimeMillis();
 		}
 		node.executor.execute(this, "UdpSocketHandler for port "+listenPort);
-		if(!disableHangChecker) {
-			node.executor.execute(new USMChecker(), "UdpSocketHandler watchdog");
-		}
 	}
-	
-	public class USMChecker implements PrioRunnable {
-		public void run() {
-		    freenet.support.Logger.OSThread.logPID(this);
-			while(true) {
-				if(_isDone) {
-					boolean active;
-					// Gone now, little reason to synchronize; particularly for reading a primitive.
-					// The EvilJVM bug may deadlock on proper synchronization here anyway.
-						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);
-				} catch (InterruptedException e) {
-					// Ignore
-				}
-				if(_thread == null || _thread.isAlive()) {
-					if(logMINOR) Logger.minor(this, "PING on "+UdpSocketHandler.this);
-					long time = System.currentTimeMillis();
-					int timeSecs = (int) (time / 1000);
-					if(timeSecs - lastTimeInSeconds > 3*60) {
-						
-						// USM has hung.
-						// Probably caused by the EvilJVMBug (see PacketSender).
-						// We'd better restart... :(
-						
-						LoggingConfigHandler lch = Node.logConfigHandler;
-						FileLoggerHook flh = lch == null ? null : lch.getFileLoggerHook();
-						boolean hasRedirected = flh == null ? false : flh.hasRedirectedStdOutErrNoLock();
-						
-						if(!hasRedirected)
-							System.err.println("Restarting node: MessageCore froze for 3 minutes!");
-						
-						try {
-							if(node.isUsingWrapper()){
-								WrapperManager.requestThreadDump();
-								WrapperManager.restart();
-							}else{
-								if(!hasRedirected)
-									System.err.println("Exiting on deadlock, but not running in the wrapper! Please restart the node manually.");
-								
-								// No wrapper : we don't want to let it harm the network!
-								node.exit("USM deadlock");
-							}
-						} catch (Throwable t) {
-							if(!hasRedirected) {
-								System.err.println("Error : can't restart the node : consider installing the wrapper. PLEASE REPORT THAT ERROR TO [email protected]");
-								t.printStackTrace();
-							}
-							node.exit("USM deadlock and error");
-						}
-					}
-				} else {
-					if(_isDone) return;
-					Logger.error(this, "MAIN LOOP TERMINATED");
-					System.err.println("MAIN LOOP TERMINATED!");
-					node.exit(NodeInitException.EXIT_MAIN_LOOP_LOST);
-				}
-			}
-		}
 
-		public int getPriority() {
-			return NativeThread.MAX_PRIORITY;
-		}
-	}
-
     public void close() {
     	Logger.normal(this, "Closing.", new Exception("error"));
 		synchronized (this) {

Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java	2009-04-08 05:02:45 UTC (rev 26633)
+++ trunk/freenet/src/freenet/node/Node.java	2009-04-08 05:03:11 UTC (rev 26634)
@@ -2280,7 +2280,7 @@
 		uptime.start();
 		failureTable.start();
 		
-		darknetCrypto.start(disableHangCheckers);
+		darknetCrypto.start();
 		if(opennet != null)
 			opennet.start();
 		ps.start(nodeStats);

Modified: trunk/freenet/src/freenet/node/NodeCrypto.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeCrypto.java	2009-04-08 05:02:45 UTC (rev 26633)
+++ trunk/freenet/src/freenet/node/NodeCrypto.java	2009-04-08 05:03:11 UTC (rev 26634)
@@ -272,9 +272,9 @@
 		node.random.nextBytes(clientNonce);
 	}
 
-	public void start(boolean disableHangchecker) {
+	public void start() {
 		packetMangler.start();
-		socket.start(disableHangchecker);
+		socket.start();
 	}
 	
 	public SimpleFieldSet exportPrivateFieldSet() {

Modified: trunk/freenet/src/freenet/node/OpennetManager.java
===================================================================
--- trunk/freenet/src/freenet/node/OpennetManager.java	2009-04-08 05:02:45 UTC (rev 26633)
+++ trunk/freenet/src/freenet/node/OpennetManager.java	2009-04-08 05:03:11 UTC (rev 26634)
@@ -222,7 +222,7 @@
 	}
 
 	public void start() {
-		crypto.start(node.disableHangCheckers);
+		crypto.start();
 		if(announcer!= null)
 			announcer.start();
 	}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.