Streaming: Kill accept() when session disconnects

This commit is contained in:
zzz
2016-07-16 16:59:07 +00:00
parent 7f2bd164db
commit 37ebf04bb5
4 changed files with 13 additions and 9 deletions

View File

@ -54,15 +54,14 @@ class ConnectionHandler {
if (_log.shouldLog(Log.WARN))
_log.warn("setActive(" + active + ") called, previously " + _active, new Exception("I did it"));
// if starting, clear any old poison
// if stopping, the accept() loop will clear any pending sockets
if (active && !_active)
_synQueue.clear();
boolean wasActive = _active;
_active = active;
if (wasActive && !active) {
try {
_synQueue.put(new PoisonPacket()); // so we break from the accept() - waits until space is available
} catch (InterruptedException ie) {}
// stopping, clear any pending sockets
_synQueue.clear();
_synQueue.offer(new PoisonPacket());
}
}

View File

@ -103,6 +103,8 @@ class MessageHandler implements I2PSessionMuxedListener {
if (_log.shouldLog(Log.WARN))
_log.warn("I2PSession disconnected");
_manager.disconnectAllHard();
// kill anybody waiting in accept()
_manager.getConnectionHandler().setActive(false);
for (I2PSocketManager.DisconnectListener lsnr : _listeners) {
lsnr.sessionDisconnected();
@ -119,9 +121,7 @@ class MessageHandler implements I2PSessionMuxedListener {
*/
public void errorOccurred(I2PSession session, String message, Throwable error) {
if (_log.shouldLog(Log.WARN))
_log.warn("error occurred: " + message + "- " + error.getMessage());
if (_log.shouldLog(Log.WARN))
_log.warn("cause", error);
_log.warn("error occurred: " + message + "- " + error.getMessage(), error);
//_manager.disconnectAllHard();
}