Author: toad
Date: 2006-06-07 11:42:20 +0000 (Wed, 07 Jun 2006)
New Revision: 9069
Modified:
trunk/freenet/src/freenet/node/PacketSender.java
trunk/freenet/src/freenet/node/Version.java
trunk/freenet/src/freenet/support/FileLoggerHook.java
Log:
781: Fix the deadlock detector. (Still getting deadlocks with 1.5.0-07, the
deadlock detector thread failed!)
Modified: trunk/freenet/src/freenet/node/PacketSender.java
===================================================================
--- trunk/freenet/src/freenet/node/PacketSender.java 2006-06-07 09:31:10 UTC
(rev 9068)
+++ trunk/freenet/src/freenet/node/PacketSender.java 2006-06-07 11:42:20 UTC
(rev 9069)
@@ -45,9 +45,19 @@
t1.start();
}
+ /**
+ * The main purpose of this thread is to detect the lost-lock deadlocks
that happen occasionally
+ * on Sun VMs with NPTL enabled, and restart the node.
+ *
+ * Consequently it MUST NOT LOCK ANYTHING. That further means it must not
use the Logger, and even
+ * System.err/System.out if they have been redirected.
+ * @author root
+ *
+ */
private class Watchdog implements Runnable {
public void run() {
+ // Do not lock anything, or we may be caught up with a
lost-lock deadlock.
while(true) {
try {
Thread.sleep(5000);
@@ -57,10 +67,9 @@
long now = System.currentTimeMillis();
long recordedTime = ((long)lastTimeInSeconds) *
1000;
long diff = now - recordedTime;
- Logger.minor(this, "PacketSender last updated
time "+diff+"ms ago");
if(diff > 3*60*1000) {
- System.err.println("Restarting node:
PacketSender froze for 3 minutes! ("+diff+")");
- Logger.error(this, "Restarting node:
PacketSender froze for 3 minutes! ("+diff+")");
+
if(!Node.logConfigHandler.getFileLoggerHook().hasRedirectedStdOutErrNoLock())
+ System.err.println("Restarting
node: PacketSender froze for 3 minutes! ("+diff+")");
try {
if(node.isUsingWrapper()){
@@ -68,11 +77,13 @@
WrapperManager.restart();
}else{
// No wrapper : we
don't want to let it harm the network!
-
Logger.error(this,"Error : can't restart the node : consider installing the
wrapper. PLEASE REPORT THAT ERROR TO devl at freenetproject.org");
node.exit();
}
} catch (Throwable t) {
- Logger.error(this,"Error :
can't restart the node : consider installing the wrapper. PLEASE REPORT THAT
ERROR TO devl at freenetproject.org");
+
if(!Node.logConfigHandler.getFileLoggerHook().hasRedirectedStdOutErrNoLock()) {
+
System.err.println("Error : can't restart the node : consider installing the
wrapper. PLEASE REPORT THAT ERROR TO devl at freenetproject.org");
+ t.printStackTrace();
+ }
node.exit();
}
Modified: trunk/freenet/src/freenet/node/Version.java
===================================================================
--- trunk/freenet/src/freenet/node/Version.java 2006-06-07 09:31:10 UTC (rev
9068)
+++ trunk/freenet/src/freenet/node/Version.java 2006-06-07 11:42:20 UTC (rev
9069)
@@ -18,7 +18,7 @@
public static final String protocolVersion = "1.0";
/** The build number of the current revision */
- private static final int buildNumber = 781;
+ private static final int buildNumber = 782;
/** Oldest build of Fred we will talk to */
private static final int lastGoodBuild = 765;
Modified: trunk/freenet/src/freenet/support/FileLoggerHook.java
===================================================================
--- trunk/freenet/src/freenet/support/FileLoggerHook.java 2006-06-07
09:31:10 UTC (rev 9068)
+++ trunk/freenet/src/freenet/support/FileLoggerHook.java 2006-06-07
11:42:20 UTC (rev 9069)
@@ -979,4 +979,11 @@
}
}
}
+
+ /**
+ * This is used by the lost-lock deadlock detector so MUST NOT TAKE A
LOCK ever!
+ */
+ public boolean hasRedirectedStdOutErrNoLock() {
+ return redirectStdOut || redirectStdErr;
+ }
}