Hopeful BOB fixes for orphaned tunnels.

Additional comments in TCPio addressing performance.
This commit is contained in:
sponge
2009-02-22 07:04:31 +00:00
parent fbe7e42f46
commit 8bce2fd7a2
4 changed files with 51 additions and 9 deletions

View File

@ -70,7 +70,7 @@ public class I2Plistener implements Runnable {
boolean g = false;
I2PSocket sessSocket = null;
serverSocket.setSoTimeout(100);
serverSocket.setSoTimeout(50);
database.getReadLock();
info.getReadLock();
if(info.exists("INPORT")) {

View File

@ -173,7 +173,7 @@ die: {
boolean spin = true;
while(spin) {
try {
Thread.sleep(1000); //sleep for 1000 ms (One second)
Thread.sleep(200); //sleep for 200 ms (Two thenths second)
} catch(InterruptedException e) {
// nop
}
@ -213,14 +213,21 @@ die: {
}
} // die
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");
while(tg.activeCount() + tg.activeGroupCount() != 0) {
if(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
while(tg.activeCount() + tg.activeGroupCount() != 0) {
try {
Thread.sleep(100); //sleep for 100 ms (One tenth second)
} catch(InterruptedException ex) {
// nop
}
}
}
tg.destroy();
@ -260,17 +267,33 @@ die: {
}
// This is here to catch when something fucks up REALLY bad.
if(tg != null) {
while(tg.activeCount() + tg.activeGroupCount() != 0) {
if(tg.activeCount() + tg.activeGroupCount() != 0) {
tg.interrupt(); // unwedge any blocking threads.
while(tg.activeCount() + tg.activeGroupCount() != 0) {
try {
Thread.sleep(100); //sleep for 100 ms (One tenth second)
} catch(InterruptedException ex) {
// nop
}
}
}
tg.destroy();
// Zap reference to the ThreadGroup so the JVM can GC it.
tg = null;
}
// Lastly try to close things again.
if(this.come_in) {
try {
listener.close();
} catch(IOException e) {
}
}
try {
socketManager.destroySocketManager();
} catch(Exception e) {
// nop
}
}
}

View File

@ -56,9 +56,28 @@ public class TCPio implements Runnable {
* Copy from source to destination...
* and yes, we are totally OK to block here on writes,
* The OS has buffers, and I intend to use them.
* We send an interrupt signal to the threadgroup to
* unwedge any pending writes.
*
*/
public void run() {
/*
* NOTE:
* The write method of OutputStream calls the write method of
* one argument on each of the bytes to be written out.
* Subclasses are encouraged to override this method and provide
* a more efficient implementation.
*
* So, is this really a performance problem?
* Should we expand to several bytes?
* I don't believe there would be any gain, since read method
* has the same reccomendations. If anyone has a better way to
* do this, I'm interested in performance improvements.
*
* --Sponge
*
*/
int b;
byte a[] = new byte[1];
boolean spin = true;

View File

@ -77,7 +77,7 @@ public class TCPlistener implements Runnable {
}
try {
Socket server = new Socket();
listener.setSoTimeout(1000);
listener.setSoTimeout(50); // Half of the expected time from MUXlisten
info.releaseReadLock();
database.releaseReadLock();
while(spin) {