SSU: Fix NPE when SSU2 disabled

This commit is contained in:
zzz
2022-12-26 07:21:49 -05:00
parent d16aaab35f
commit d655ad206c
2 changed files with 25 additions and 22 deletions

View File

@@ -3213,32 +3213,35 @@ class EstablishmentManager {
_log.warn("Failsafe remove OBBH " + state);
}
}
int count = 0;
synchronized(_inboundTokens) {
for (Iterator<Token> iter = _inboundTokens.values().iterator(); iter.hasNext(); ) {
Token tok = iter.next();
if (tok.getExpiration() < now) {
iter.remove();
count++;
if (_inboundTokens != null) {
// SSU2 only
int count = 0;
synchronized(_inboundTokens) {
for (Iterator<Token> iter = _inboundTokens.values().iterator(); iter.hasNext(); ) {
Token tok = iter.next();
if (tok.getExpiration() < now) {
iter.remove();
count++;
}
}
}
}
if (count > 0 && _log.shouldDebug())
_log.debug("Expired " + count + " inbound tokens");
count = 0;
synchronized(_outboundTokens) {
for (Iterator<Token> iter = _outboundTokens.values().iterator(); iter.hasNext(); ) {
Token tok = iter.next();
if (tok.getExpiration() < now) {
iter.remove();
count++;
if (count > 0 && _log.shouldDebug())
_log.debug("Expired " + count + " inbound tokens");
count = 0;
synchronized(_outboundTokens) {
for (Iterator<Token> iter = _outboundTokens.values().iterator(); iter.hasNext(); ) {
Token tok = iter.next();
if (tok.getExpiration() < now) {
iter.remove();
count++;
}
}
}
if (count > 0 && _log.shouldDebug())
_log.debug("Expired " + count + " outbound tokens");
_terminationCounter.clear();
_transport.getIntroManager().cleanup();
}
if (count > 0 && _log.shouldDebug())
_log.debug("Expired " + count + " outbound tokens");
_terminationCounter.clear();
_transport.getIntroManager().cleanup();
}
}
}

View File

@@ -1291,7 +1291,7 @@ class IntroductionManager {
* @since 0.9.57
*/
public void cleanup() {
if (_nonceToAlice.isEmpty())
if (_nonceToAlice == null || _nonceToAlice.isEmpty())
return;
for (Iterator<PeerState2> iter = _nonceToAlice.values().iterator(); iter.hasNext(); ) {
PeerState2 state = iter.next();