2009-04-08 sponge

* More hopeful fixups to the infamous orpahned tunnel problem. *Sigh*
This commit is contained in:
sponge
2009-04-08 11:55:51 +00:00
parent f9f9aa4498
commit 8f690a8f67
4 changed files with 87 additions and 73 deletions

View File

@ -48,17 +48,18 @@ public class I2Plistener implements Runnable {
/**
* Constructor
* @param SS
* @param S
* @param info
* @param database
* @param _log
*/
I2Plistener(I2PSocketManager S, NamedDB info, NamedDB database, Log _log) {
I2Plistener(I2PServerSocket SS, I2PSocketManager S, NamedDB info, NamedDB database, Log _log) {
this.database = database;
this.info = info;
this._log = _log;
this.socketManager = S;
serverSocket = this.socketManager.getServerSocket();
serverSocket = SS;
tgwatch = 1;
}
@ -72,16 +73,6 @@ public class I2Plistener implements Runnable {
info.releaseReadLock();
}
private void wlock() throws Exception {
database.getWriteLock();
info.getWriteLock();
}
private void wunlock() throws Exception {
info.releaseWriteLock();
database.releaseWriteLock();
}
/**
* Simply listen on I2P port, and thread connections
*

View File

@ -28,7 +28,10 @@ import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.i2p.I2PException;
import net.i2p.client.streaming.I2PServerSocket;
import net.i2p.client.streaming.I2PSocketManager;
import net.i2p.client.streaming.I2PSocketManagerFactory;
import net.i2p.util.Log;
@ -130,7 +133,7 @@ public class MUXlisten implements Runnable {
*
*/
public void run() {
I2PServerSocket SS = null;
try {
wlock();
try {
@ -148,17 +151,21 @@ public class MUXlisten implements Runnable {
} catch (Exception e) {
return;
}
// socketManager.addDisconnectListener(new DisconnectListener());
quit: {
quit:
{
try {
tg = new ThreadGroup(N);
die: {
die:
{
// toss the connections to a new threads.
// will wrap with TCP and UDP when UDP works
if (go_out) {
// I2P -> TCP
I2Plistener conn = new I2Plistener(socketManager, info, database, _log);
SS = socketManager.getServerSocket();
I2Plistener conn = new I2Plistener(SS, socketManager, info, database, _log);
Thread t = new Thread(tg, conn, "BOBI2Plistener " + N);
t.start();
}
@ -213,20 +220,20 @@ die: {
}
} // die
try {
Thread.sleep(500); //sleep for 500 ms (One half second)
} catch(InterruptedException ex) {
// nop
}
// try {
// Thread.sleep(500); //sleep for 500 ms (One half second)
// } catch (InterruptedException ex) {
// // nop
// }
// wait for child threads and thread groups to die
// System.out.println("MUXlisten: waiting for children");
if (tg.activeCount() + tg.activeGroupCount() != 0) {
tg.interrupt(); // unwedge any blocking threads.
while (tg.activeCount() + tg.activeGroupCount() != 0) {
tg.interrupt(); // unwedge any blocking threads.
try {
Thread.sleep(100); //sleep for 100 ms (One tenth second)
} catch (InterruptedException ex) {
// nop
// NOP
}
}
}
@ -246,25 +253,7 @@ die: {
System.out.println("BOB: MUXlisten: Something fucked up REALLY bad!");
System.out.println("BOB: MUXlisten: Please email the above dump to sponge@mail.i2p");
}
// zero out everything, just incase.
try {
socketManager.destroySocketManager();
} catch(Exception e) {
// nop
}
try {
wlock();
try {
info.add("STARTING", new Boolean(false));
info.add("STOPPING", new Boolean(false));
info.add("RUNNING", new Boolean(false));
} catch(Exception e) {
wunlock();
return;
}
wunlock();
} catch(Exception e) {
}
// This is here to catch when something fucks up REALLY bad.
if (tg != null) {
if (tg.activeCount() + tg.activeGroupCount() != 0) {
@ -282,6 +271,13 @@ die: {
tg = null;
}
if (SS != null) {
try {
SS.close();
} catch (I2PException ex) {
//Logger.getLogger(MUXlisten.class.getName()).log(Level.SEVERE, null, ex);
}
}
// Lastly try to close things again.
if (this.come_in) {
try {
@ -294,6 +290,30 @@ die: {
} catch (Exception e) {
// nop
}
// zero out everything.
try {
wlock();
try {
info.add("STARTING", new Boolean(false));
info.add("STOPPING", new Boolean(false));
info.add("RUNNING", new Boolean(false));
} catch (Exception e) {
wunlock();
return;
}
wunlock();
} catch (Exception e) {
}
}
// private class DisconnectListener implements I2PSocketManager.DisconnectListener {
//
// public void sessionDisconnected() {
// close();
// }
// }
// public void close() {
// socketManager.destroySocketManager();
// }
}

View File

@ -1,3 +1,6 @@
2009-04-08 sponge
* More hopeful fixups to the infamous orpahned tunnel problem. *Sigh*
2009-04-08 zzz
* IPV6/localhost:
- Enable IPv6 stack in the JVM, hopefully won't break anything

View File

@ -17,7 +17,7 @@ import net.i2p.CoreVersion;
public class RouterVersion {
public final static String ID = "$Revision: 1.548 $ $Date: 2008-06-07 23:00:00 $";
public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 13;
public final static long BUILD = 14;
public static void main(String args[]) {
System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
System.out.println("Router ID: " + RouterVersion.ID);