Hopeful BOB fixes for orphaned tunnels.
Additional comments in TCPio addressing performance.
This commit is contained in:
@ -70,7 +70,7 @@ public class I2Plistener implements Runnable {
|
|||||||
boolean g = false;
|
boolean g = false;
|
||||||
I2PSocket sessSocket = null;
|
I2PSocket sessSocket = null;
|
||||||
|
|
||||||
serverSocket.setSoTimeout(100);
|
serverSocket.setSoTimeout(50);
|
||||||
database.getReadLock();
|
database.getReadLock();
|
||||||
info.getReadLock();
|
info.getReadLock();
|
||||||
if(info.exists("INPORT")) {
|
if(info.exists("INPORT")) {
|
||||||
|
@ -173,7 +173,7 @@ die: {
|
|||||||
boolean spin = true;
|
boolean spin = true;
|
||||||
while(spin) {
|
while(spin) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(1000); //sleep for 1000 ms (One second)
|
Thread.sleep(200); //sleep for 200 ms (Two thenths second)
|
||||||
} catch(InterruptedException e) {
|
} catch(InterruptedException e) {
|
||||||
// nop
|
// nop
|
||||||
}
|
}
|
||||||
@ -213,16 +213,23 @@ die: {
|
|||||||
}
|
}
|
||||||
} // 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
|
// wait for child threads and thread groups to die
|
||||||
// System.out.println("MUXlisten: waiting for children");
|
// 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.
|
tg.interrupt(); // unwedge any blocking threads.
|
||||||
|
while(tg.activeCount() + tg.activeGroupCount() != 0) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(100); //sleep for 100 ms (One tenth second)
|
Thread.sleep(100); //sleep for 100 ms (One tenth second)
|
||||||
} catch(InterruptedException ex) {
|
} catch(InterruptedException ex) {
|
||||||
// nop
|
// nop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
tg.destroy();
|
tg.destroy();
|
||||||
// Zap reference to the ThreadGroup so the JVM can GC it.
|
// Zap reference to the ThreadGroup so the JVM can GC it.
|
||||||
tg = null;
|
tg = null;
|
||||||
@ -260,17 +267,33 @@ die: {
|
|||||||
}
|
}
|
||||||
// This is here to catch when something fucks up REALLY bad.
|
// This is here to catch when something fucks up REALLY bad.
|
||||||
if(tg != null) {
|
if(tg != null) {
|
||||||
while(tg.activeCount() + tg.activeGroupCount() != 0) {
|
if(tg.activeCount() + tg.activeGroupCount() != 0) {
|
||||||
tg.interrupt(); // unwedge any blocking threads.
|
tg.interrupt(); // unwedge any blocking threads.
|
||||||
|
while(tg.activeCount() + tg.activeGroupCount() != 0) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(100); //sleep for 100 ms (One tenth second)
|
Thread.sleep(100); //sleep for 100 ms (One tenth second)
|
||||||
} catch(InterruptedException ex) {
|
} catch(InterruptedException ex) {
|
||||||
// nop
|
// nop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
tg.destroy();
|
tg.destroy();
|
||||||
// Zap reference to the ThreadGroup so the JVM can GC it.
|
// Zap reference to the ThreadGroup so the JVM can GC it.
|
||||||
tg = null;
|
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
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,9 +56,28 @@ public class TCPio implements Runnable {
|
|||||||
* Copy from source to destination...
|
* Copy from source to destination...
|
||||||
* and yes, we are totally OK to block here on writes,
|
* and yes, we are totally OK to block here on writes,
|
||||||
* The OS has buffers, and I intend to use them.
|
* 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() {
|
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;
|
int b;
|
||||||
byte a[] = new byte[1];
|
byte a[] = new byte[1];
|
||||||
boolean spin = true;
|
boolean spin = true;
|
||||||
|
@ -77,7 +77,7 @@ public class TCPlistener implements Runnable {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Socket server = new Socket();
|
Socket server = new Socket();
|
||||||
listener.setSoTimeout(1000);
|
listener.setSoTimeout(50); // Half of the expected time from MUXlisten
|
||||||
info.releaseReadLock();
|
info.releaseReadLock();
|
||||||
database.releaseReadLock();
|
database.releaseReadLock();
|
||||||
while(spin) {
|
while(spin) {
|
||||||
|
Reference in New Issue
Block a user