Compare commits

...

1 Commits

4 changed files with 26 additions and 7 deletions

View File

@ -211,18 +211,19 @@ class ClientConnectionRunner {
_manager.unregisterEncryptedDestination(this, _encryptedLSHash); _manager.unregisterEncryptedDestination(this, _encryptedLSHash);
_manager.unregisterConnection(this); _manager.unregisterConnection(this);
// netdb may be null in unit tests // netdb may be null in unit tests
if (_context.netDb() != null) { String dbid = this.getDestHash().toBase32();
if (_context.netDb().getSubNetDB(dbid) != null) {
// Note that if the client sent us a destroy message, // Note that if the client sent us a destroy message,
// removeSession() was called just before this, and // removeSession() was called just before this, and
// _sessions will be empty. // _sessions will be empty.
for (SessionParams sp : _sessions.values()) { for (SessionParams sp : _sessions.values()) {
LeaseSet ls = sp.currentLeaseSet; LeaseSet ls = sp.currentLeaseSet;
if (ls != null) if (ls != null)
_context.netDb().unpublish(ls); _context.netDb().getSubNetDB(dbid).unpublish(ls);
// unpublish encrypted LS also // unpublish encrypted LS also
ls = sp.currentEncryptedLeaseSet; ls = sp.currentEncryptedLeaseSet;
if (ls != null) if (ls != null)
_context.netDb().unpublish(ls); _context.netDb().getSubNetDB(dbid).unpublish(ls);
if (!sp.isPrimary) if (!sp.isPrimary)
_context.tunnelManager().removeAlias(sp.dest); _context.tunnelManager().removeAlias(sp.dest);
} }
@ -448,6 +449,7 @@ class ClientConnectionRunner {
if (id == null) if (id == null)
return; return;
boolean isPrimary = false; boolean isPrimary = false;
String dbid = this.getDestHash().toBase32();
for (Iterator<SessionParams> iter = _sessions.values().iterator(); iter.hasNext(); ) { for (Iterator<SessionParams> iter = _sessions.values().iterator(); iter.hasNext(); ) {
SessionParams sp = iter.next(); SessionParams sp = iter.next();
if (id.equals(sp.sessionId)) { if (id.equals(sp.sessionId)) {
@ -458,11 +460,11 @@ class ClientConnectionRunner {
_manager.unregisterSession(id, sp.dest); _manager.unregisterSession(id, sp.dest);
LeaseSet ls = sp.currentLeaseSet; LeaseSet ls = sp.currentLeaseSet;
if (ls != null) if (ls != null)
_context.netDb().unpublish(ls); _context.netDb().getSubNetDB(dbid).unpublish(ls);
// unpublish encrypted LS also // unpublish encrypted LS also
ls = sp.currentEncryptedLeaseSet; ls = sp.currentEncryptedLeaseSet;
if (ls != null) if (ls != null)
_context.netDb().unpublish(ls); _context.netDb().getSubNetDB(dbid).unpublish(ls);
isPrimary = sp.isPrimary; isPrimary = sp.isPrimary;
if (isPrimary) if (isPrimary)
_context.tunnelManager().removeTunnels(sp.dest); _context.tunnelManager().removeTunnels(sp.dest);
@ -483,11 +485,11 @@ class ClientConnectionRunner {
_manager.unregisterSession(sp.sessionId, sp.dest); _manager.unregisterSession(sp.sessionId, sp.dest);
LeaseSet ls = sp.currentLeaseSet; LeaseSet ls = sp.currentLeaseSet;
if (ls != null) if (ls != null)
_context.netDb().unpublish(ls); _context.netDb().getSubNetDB(dbid).unpublish(ls);
// unpublish encrypted LS also // unpublish encrypted LS also
ls = sp.currentEncryptedLeaseSet; ls = sp.currentEncryptedLeaseSet;
if (ls != null) if (ls != null)
_context.netDb().unpublish(ls); _context.netDb().getSubNetDB(dbid).unpublish(ls);
_context.tunnelManager().removeAlias(sp.dest); _context.tunnelManager().removeAlias(sp.dest);
synchronized(this) { synchronized(this) {
if (sp.rerequestTimer != null) if (sp.rerequestTimer != null)

View File

@ -44,6 +44,7 @@ public class DummyNetworkDatabaseFacade extends SegmentedNetworkDatabaseFacade {
public void restart() {} public void restart() {}
public void shutdown() {} public void shutdown() {}
public void remove(String dbid){}
public void startup() { public void startup() {
RouterInfo info = _context.router().getRouterInfo(); RouterInfo info = _context.router().getRouterInfo();
_routers.put(info.getIdentity().getHash(), info); _routers.put(info.getIdentity().getHash(), info);

View File

@ -956,4 +956,18 @@ public class FloodfillNetworkDatabaseSegmentor extends SegmentedNetworkDatabaseF
} }
return null; return null;
} }
public void remove(String dbid) {
if (dbid != null) {
if (dbid.endsWith(".i2p") && !dbid.startsWith("clients_"))
dbid = "clients_" + dbid;
else if (dbid.equals(""))
dbid = MAIN_DBID;
GetSubNetDB(dbid).shutdown();
_subDBs.remove(dbid);
} else {
if (_log.shouldLog(Log.DEBUG))
_log.debug("remove called with null dbid, refusing to remove main DB");
}
}
} }

View File

@ -332,4 +332,6 @@ public abstract class SegmentedNetworkDatabaseFacade { // extends FloodfillNetwo
} }
public abstract String getDbidByHash(Hash clientKey); public abstract String getDbidByHash(Hash clientKey);
public abstract void remove(String dbid);
} }