Author: toad
Date: 2006-05-29 20:26:22 +0000 (Mon, 29 May 2006)
New Revision: 8933

Modified:
   trunk/freenet/src/freenet/io/comm/UdpSocketManager.java
   trunk/freenet/src/freenet/node/Node.java
   trunk/freenet/src/freenet/node/NodeStarter.java
   trunk/freenet/src/freenet/node/Version.java
Log:
751:
Daemonize USM, and start a "plug" non-daemon thread (everything else is daemon).
This may prevent the EvilJVMBug, according to 
http://forum.java.sun.com/thread.jspa?threadID=343023&messageID=2942637
Thanks mrogers for finding this!

Modified: trunk/freenet/src/freenet/io/comm/UdpSocketManager.java
===================================================================
--- trunk/freenet/src/freenet/io/comm/UdpSocketManager.java     2006-05-29 
20:13:33 UTC (rev 8932)
+++ trunk/freenet/src/freenet/io/comm/UdpSocketManager.java     2006-05-29 
20:26:22 UTC (rev 8933)
@@ -49,6 +49,7 @@
        }

        public void start() {
+               setDaemon(true);
                setPriority(Thread.MAX_PRIORITY);
                super.start();
                Thread checker = new Thread(new USMChecker());

Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java    2006-05-29 20:13:33 UTC (rev 
8932)
+++ trunk/freenet/src/freenet/node/Node.java    2006-05-29 20:26:22 UTC (rev 
8933)
@@ -821,6 +821,27 @@
                        e.printStackTrace();
                        System.exit(e.exitCode);
                }
+
+               // Thread to keep the node up.
+               // JVM deadlocks losing a lock when two threads of different 
types (daemon|app)
+               // are contended for the same lock. So make USM daemon, and use 
useless to keep the JVM
+               // up.
+               // 
http://forum.java.sun.com/thread.jspa?threadID=343023&messageID=2942637 - last 
message
+               Runnable useless =
+                       new Runnable() {
+                       public void run() {
+                               while(true)
+                                       try {
+                                               Thread.sleep(Long.MAX_VALUE);
+                                       } catch (InterruptedException e) {
+                                               // Ignore
+                                       }
+                       }
+               };
+               Thread plug = new Thread(useless, "Plug");
+               plug.start();
+               
+
     }

     static class NodeInitException extends Exception {

Modified: trunk/freenet/src/freenet/node/NodeStarter.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeStarter.java     2006-05-29 20:13:33 UTC 
(rev 8932)
+++ trunk/freenet/src/freenet/node/NodeStarter.java     2006-05-29 20:26:22 UTC 
(rev 8933)
@@ -107,7 +107,25 @@
        t.setPriority(Thread.MAX_PRIORITY);
        t.start();

-        
+               // Thread to keep the node up.
+               // JVM deadlocks losing a lock when two threads of different 
types (daemon|app)
+               // are contended for the same lock. So make USM daemon, and use 
useless to keep the JVM
+               // up.
+               // 
http://forum.java.sun.com/thread.jspa?threadID=343023&messageID=2942637 - last 
message
+               Runnable useless =
+                       new Runnable() {
+                       public void run() {
+                               while(true)
+                                       try {
+                                               Thread.sleep(Long.MAX_VALUE);
+                                       } catch (InterruptedException e) {
+                                               // Ignore
+                                       }
+                       }
+               };
+               Thread plug = new Thread(useless, "Plug");
+               plug.start();
+               
        WrapperManager.signalStarting(500000);
        try {
                node = new Node(cfg, random, logConfigHandler,this);
@@ -117,7 +135,8 @@
                e.printStackTrace();
                System.exit(e.exitCode);
        }
-       return null;
+       
+               return null;
     }

     /**

Modified: trunk/freenet/src/freenet/node/Version.java
===================================================================
--- trunk/freenet/src/freenet/node/Version.java 2006-05-29 20:13:33 UTC (rev 
8932)
+++ trunk/freenet/src/freenet/node/Version.java 2006-05-29 20:26:22 UTC (rev 
8933)
@@ -18,7 +18,7 @@
        public static final String protocolVersion = "1.0";

        /** The build number of the current revision */
-       private static final int buildNumber = 750;
+       private static final int buildNumber = 751;

        /** Oldest build of Fred we will talk to */
        private static final int lastGoodBuild = 732;


Reply via email to