Router: Fix corner cases maintaining local leasesets (ticket #1768)

This commit is contained in:
zzz
2016-03-14 15:13:26 +00:00
parent 2e3f5d0de9
commit 319d40146d
5 changed files with 30 additions and 5 deletions

View File

@@ -1,3 +1,10 @@
2016-03-14 zzz
* Console: Replace pastethis with zerobin
* Peer selection: Don't truncate data used for random slice
* Router: Fix corner cases maintaining local leasesets (ticket #1768)
* Susimail: Fix NPE
* UPnP: Fix NPE in HTML output on /peers (ticket #1779)
2016-03-01 zzz 2016-03-01 zzz
* i2psnark: Fix handling of HAVE messages received before metainfo * i2psnark: Fix handling of HAVE messages received before metainfo
* i2ptunnel: Don't default to a private key file that exists (ticket #1628) * i2ptunnel: Don't default to a private key file that exists (ticket #1628)

View File

@@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */ /** deprecated */
public final static String ID = "Monotone"; public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION; public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 11; public final static long BUILD = 12;
/** for example "-test" */ /** for example "-test" */
public final static String EXTRA = "-rc"; public final static String EXTRA = "-rc";

View File

@@ -292,6 +292,7 @@ class ClientConnectionRunner {
* Currently allocated leaseSet. * Currently allocated leaseSet.
* IS subsession aware. * IS subsession aware.
*/ */
/****
void setLeaseSet(LeaseSet ls) { void setLeaseSet(LeaseSet ls) {
Hash h = ls.getDestination().calculateHash(); Hash h = ls.getDestination().calculateHash();
SessionParams sp = _sessions.get(h); SessionParams sp = _sessions.get(h);
@@ -299,6 +300,7 @@ class ClientConnectionRunner {
return; return;
sp.currentLeaseSet = ls; sp.currentLeaseSet = ls;
} }
****/
/** /**
* Equivalent to getConfig().getDestination().calculateHash(); * Equivalent to getConfig().getDestination().calculateHash();
@@ -590,14 +592,16 @@ class ClientConnectionRunner {
return; return;
LeaseRequestState state; LeaseRequestState state;
synchronized (this) { synchronized (this) {
sp.currentLeaseSet = ls;
state = sp.leaseRequest; state = sp.leaseRequest;
if (state == null) { if (state == null) {
// We got the LS after the timeout?
// ClientMessageEventListener told the router to publish.
if (_log.shouldLog(Log.WARN)) if (_log.shouldLog(Log.WARN))
_log.warn("LeaseRequest is null and we've received a new lease?! perhaps this is odd... " + ls); _log.warn("LeaseRequest is null and we've received a new lease? " + ls);
return; return;
} else { } else {
state.setIsSuccessful(true); state.setIsSuccessful(true);
setLeaseSet(ls);
if (_log.shouldLog(Log.DEBUG)) if (_log.shouldLog(Log.DEBUG))
_log.debug("LeaseSet created fully: " + state + " / " + ls); _log.debug("LeaseSet created fully: " + state + " / " + ls);
sp.leaseRequest = null; sp.leaseRequest = null;
@@ -1071,7 +1075,7 @@ class ClientConnectionRunner {
synchronized (_alreadyProcessed) { synchronized (_alreadyProcessed) {
inLock = _context.clock().now(); inLock = _context.clock().now();
if (_alreadyProcessed.contains(_messageId)) { if (_alreadyProcessed.contains(_messageId)) {
_log.warn("Status already updated"); _log.info("Status already updated");
alreadyProcessed = true; alreadyProcessed = true;
} else { } else {
_alreadyProcessed.add(_messageId); _alreadyProcessed.add(_messageId);

View File

@@ -13,6 +13,7 @@ import java.io.Writer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@@ -236,6 +237,17 @@ class ClientManager {
_runners.remove(dest); _runners.remove(dest);
_runnersByHash.remove(dest.calculateHash()); _runnersByHash.remove(dest.calculateHash());
} }
// just in case
for (Iterator<ClientConnectionRunner> iter = _runners.values().iterator(); iter.hasNext(); ) {
ClientConnectionRunner r = iter.next();
if (r.equals(runner))
iter.remove();
}
for (Iterator<ClientConnectionRunner> iter = _runnersByHash.values().iterator(); iter.hasNext(); ) {
ClientConnectionRunner r = iter.next();
if (r.equals(runner))
iter.remove();
}
} }
} }

View File

@@ -65,8 +65,10 @@ class RequestLeaseSetJob extends JobImpl {
endTime += fudge; endTime += fudge;
SessionId id = _runner.getSessionId(requested.getDestination().calculateHash()); SessionId id = _runner.getSessionId(requested.getDestination().calculateHash());
if (id == null) if (id == null) {
_runner.failLeaseRequest(_requestState);
return; return;
}
I2CPMessage msg; I2CPMessage msg;
if (getContext().getProperty(PROP_VARIABLE, DFLT_VARIABLE) && if (getContext().getProperty(PROP_VARIABLE, DFLT_VARIABLE) &&
(_runner instanceof QueuedClientConnectionRunner || (_runner instanceof QueuedClientConnectionRunner ||