From 66a292a9c6c8a083794db9a839a50a598cd407ce Mon Sep 17 00:00:00 2001 From: sponge Date: Tue, 12 May 2009 21:10:42 +0000 Subject: [PATCH] 2009-05-12 sponge * BOB clean up, change println's to _log.warn, bump BOB version * I2PSessionMuxedImpl.java changes as per zzz, and they test OK for me. --- apps/BOB/src/net/i2p/BOB/DoCMDS.java | 2 +- apps/BOB/src/net/i2p/BOB/MUXlisten.java | 42 ++++++------------- .../net/i2p/client/I2PSessionMuxedImpl.java | 11 +++-- history.txt | 4 ++ .../src/net/i2p/router/RouterVersion.java | 2 +- 5 files changed, 24 insertions(+), 37 deletions(-) diff --git a/apps/BOB/src/net/i2p/BOB/DoCMDS.java b/apps/BOB/src/net/i2p/BOB/DoCMDS.java index 1a2d2a19a..4a13844cb 100644 --- a/apps/BOB/src/net/i2p/BOB/DoCMDS.java +++ b/apps/BOB/src/net/i2p/BOB/DoCMDS.java @@ -46,7 +46,7 @@ public class DoCMDS implements Runnable { // FIX ME // I need a better way to do versioning, but this will do for now. - public static final String BMAJ = "00", BMIN = "00", BREV = "05", BEXT = ""; + public static final String BMAJ = "00", BMIN = "00", BREV = "06", BEXT = ""; public static final String BOBversion = BMAJ + "." + BMIN + "." + BREV + BEXT; private Socket server; private Properties props; diff --git a/apps/BOB/src/net/i2p/BOB/MUXlisten.java b/apps/BOB/src/net/i2p/BOB/MUXlisten.java index 91028e7cb..f77d5bc82 100644 --- a/apps/BOB/src/net/i2p/BOB/MUXlisten.java +++ b/apps/BOB/src/net/i2p/BOB/MUXlisten.java @@ -235,27 +235,13 @@ public class MUXlisten implements Runnable { } } // die - // I2PSession session = socketManager.getSession(); - // if (session != null) { - // System.out.println("I2Plistener: destroySession"); - // try { - // session.destroySession(); - // } catch (I2PSessionException ex) { - // nop - // } - // } - // try { - // socketManager.destroySocketManager(); - //} catch (Exception e) { - // nop - //} } catch (Exception e) { // System.out.println("MUXlisten: Caught an exception" + e); break quit; } } // quit } finally { - // allow threads above this one to catch the stop signal. + // Start cleanup. Allow threads above this one to catch the stop signal. try { Thread.sleep(250); } catch (InterruptedException ex) { @@ -275,10 +261,6 @@ public class MUXlisten implements Runnable { } catch (Exception e) { } - //try { - // Thread.sleep(1000 * 20); // how long?? is this even needed?? - //} catch (InterruptedException ex) { - //} if (SS != null) { try { @@ -292,32 +274,34 @@ public class MUXlisten implements Runnable { } catch (IOException e) { } } + try { socketManager.destroySocketManager(); } catch (Exception e) { // nop } - // This is here to catch when something fucks up REALLY bad, like those annoying stuck threads! + // Wait around till all threads are collected. if (tg != null) { String boner = tg.getName(); + _log.warn("BOB: MUXlisten: Starting thread collection for: " + boner); // tg.interrupt(); // give my stuff a small smack again. if (tg.activeCount() + tg.activeGroupCount() != 0) { int foo = tg.activeCount() + tg.activeGroupCount(); - int bar = foo; // hopefully no longer needed! + // int bar = foo; // System.out.println("BOB: MUXlisten: Waiting on threads for " + boner); - // System.out.println("\n\nBOB: MUXlisten: ThreadGroup dump BEGIN " + boner); + // System.out.println("\nBOB: MUXlisten: ThreadGroup dump BEGIN " + boner); // visit(tg, 0, boner); - // System.out.println("BOB: MUXlisten: ThreadGroup dump END " + boner + "\n\n"); + // System.out.println("BOB: MUXlisten: ThreadGroup dump END " + boner + "\n"); // Happily spin forever :-( - while ((tg.activeCount() + tg.activeGroupCount() != 0)) { + while (foo != 0) { foo = tg.activeCount() + tg.activeGroupCount(); // if (foo != bar) { - // System.out.println("\n\nBOB: MUXlisten: ThreadGroup dump BEGIN " + boner); + // System.out.println("\nBOB: MUXlisten: ThreadGroup dump BEGIN " + boner); // visit(tg, 0, boner); - // System.out.println("BOB: MUXlisten: ThreadGroup dump END " + boner + "\n\n"); + // System.out.println("BOB: MUXlisten: ThreadGroup dump END " + boner + "\n"); // } - bar = foo; + // bar = foo; try { Thread.sleep(100); //sleep for 100 ms (One tenth second) } catch (InterruptedException ex) { @@ -325,7 +309,7 @@ public class MUXlisten implements Runnable { } } } - System.out.println("BOB: MUXlisten: Threads went away. Success: " + boner); + _log.warn("BOB: MUXlisten: Threads went away. Success: " + boner); tg.destroy(); // Zap reference to the ThreadGroup so the JVM can GC it. tg = null; @@ -334,7 +318,7 @@ public class MUXlisten implements Runnable { } - // Debugging... + // Debugging... None of this is normally used. /** * Find the root thread group and print them all. * diff --git a/core/java/src/net/i2p/client/I2PSessionMuxedImpl.java b/core/java/src/net/i2p/client/I2PSessionMuxedImpl.java index ec08a8fd3..58b5cae9f 100644 --- a/core/java/src/net/i2p/client/I2PSessionMuxedImpl.java +++ b/core/java/src/net/i2p/client/I2PSessionMuxedImpl.java @@ -200,7 +200,7 @@ class I2PSessionMuxedImpl extends I2PSessionImpl2 implements I2PSession { protected class MuxedAvailabilityNotifier extends AvailabilityNotifier { private LinkedBlockingQueue _msgs; - private volatile Boolean _alive = new Boolean(false); + private volatile boolean _alive = false; private static final int POISON_SIZE = -99999; private final AtomicBoolean stopping = new AtomicBoolean(false); @@ -212,9 +212,8 @@ class I2PSessionMuxedImpl extends I2PSessionImpl2 implements I2PSession { public void stopNotifying() { boolean again = true; synchronized (stopping) { - if(!stopping.get()) { - stopping.set(true); - if (_alive.equals(true)) { + if( !stopping.getAndSet(true)) { + if (_alive == true) { // System.out.println("I2PSessionMuxedImpl.stopNotifying()"); _msgs.clear(); while(again) { @@ -230,7 +229,7 @@ class I2PSessionMuxedImpl extends I2PSessionImpl2 implements I2PSession { _alive = false; stopping.set(false); } - stopping.notifyAll(); + // stopping.notifyAll(); } } /** unused */ @@ -251,7 +250,7 @@ class I2PSessionMuxedImpl extends I2PSessionImpl2 implements I2PSession { try { msg = _msgs.take(); } catch (InterruptedException ie) { - _log.debug("I2PSessionMuxedImpl.run() InterruptedException " + String.valueOf(_msgs.size()) + " Messages, Alive " + _alive.toString()); + _log.debug("I2PSessionMuxedImpl.run() InterruptedException " + String.valueOf(_msgs.size()) + " Messages, Alive " + _alive); continue; } if (msg.size == POISON_SIZE) { diff --git a/history.txt b/history.txt index 37533d996..21ae959bc 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,7 @@ +2009-05-12 sponge + * BOB clean up, change println's to _log.warn, bump BOB version + * I2PSessionMuxedImpl.java changes as per zzz, and they test OK for me. + 2009-05-11 zzz * Connect client: Fix NPE when used with advanced i2ptunnel features * Context: Don't instantiate unused AdminManager diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index d06a930a7..e4b934bb2 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -18,7 +18,7 @@ public class RouterVersion { /** deprecated */ public final static String ID = "Monotone"; public final static String VERSION = CoreVersion.VERSION; - public final static long BUILD = 13; + public final static long BUILD = 14; /** for example "-test" */ public final static String EXTRA = ""; public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA;