send I2CP DisconnectMessage at router shutdown

This commit is contained in:
zzz
2010-11-14 14:47:43 +00:00
parent cd621f2b4b
commit d47dcddb9b
2 changed files with 20 additions and 5 deletions

View File

@@ -237,17 +237,32 @@ public class ClientConnectionRunner {
_context.jobQueue().addJob(state.getOnGranted());
}
/**
* Send a DisconnectMessage and log with level Log.CRIT.
* This is always bad.
* See ClientMessageEventListener.handleCreateSession()
* for why we don't send a SessionStatusMessage when we do this.
*/
void disconnectClient(String reason) {
if (_log.shouldLog(Log.CRIT))
_log.log(Log.CRIT, "Disconnecting the client ("
disconnectClient(reason, Log.CRIT);
}
/**
* @param logLevel e.g. Log.WARN
* @since 0.8.2
*/
void disconnectClient(String reason, int logLevel) {
if (_log.shouldLog(logLevel))
_log.log(logLevel, "Disconnecting the client ("
+ _config
+ ": " + reason);
+ ") : " + reason);
DisconnectMessage msg = new DisconnectMessage();
msg.setReason(reason);
try {
doSend(msg);
} catch (I2CPMessageException ime) {
_log.error("Error writing out the disconnect message: " + ime);
if (_log.shouldLog(Log.WARN))
_log.warn("Error writing out the disconnect message: " + ime);
}
stopRunning();
}

View File

@@ -113,7 +113,7 @@ public class ClientManager {
}
for (Iterator<ClientConnectionRunner> iter = runners.iterator(); iter.hasNext(); ) {
ClientConnectionRunner runner = iter.next();
runner.stopRunning();
runner.disconnectClient("Router shutdown", Log.WARN);
}
}