Fix removal of subsession aliases from tunnel manager on

I2CP connection shutdown
Sort tweaks for shared clients in summary bar
This commit is contained in:
zzz
2015-06-15 14:35:15 +00:00
parent 2b9ffc1270
commit bc85543ef2
4 changed files with 16 additions and 8 deletions

View File

@ -491,9 +491,11 @@ public class SummaryHelper extends HelperBase {
public int compare(Destination lhs, Destination rhs) { public int compare(Destination lhs, Destination rhs) {
String lname = getName(lhs); String lname = getName(lhs);
String rname = getName(rhs); String rname = getName(rhs);
if (lname.equals(xsc)) boolean lshared = lname.startsWith("shared clients") || lname.startsWith(xsc);
boolean rshared = rname.startsWith("shared clients") || rname.startsWith(xsc);
if (lshared && !rshared)
return -1; return -1;
if (rname.equals(xsc)) if (rshared && !lshared)
return 1; return 1;
return Collator.getInstance().compare(lname, rname); return Collator.getInstance().compare(lname, rname);
} }

View File

@ -202,6 +202,8 @@ class ClientConnectionRunner {
LeaseSet ls = sp.currentLeaseSet; LeaseSet ls = sp.currentLeaseSet;
if (ls != null) if (ls != null)
_context.netDb().unpublish(ls); _context.netDb().unpublish(ls);
if (!sp.isPrimary)
_context.tunnelManager().removeAlias(sp.dest);
} }
synchronized (_alreadyProcessed) { synchronized (_alreadyProcessed) {
_alreadyProcessed.clear(); _alreadyProcessed.clear();
@ -414,15 +416,21 @@ class ClientConnectionRunner {
if (ls != null) if (ls != null)
_context.netDb().unpublish(ls); _context.netDb().unpublish(ls);
isPrimary = sp.isPrimary; isPrimary = sp.isPrimary;
if (!isPrimary)
_context.tunnelManager().removeAlias(sp.dest);
break;
} }
} }
if (isPrimary) { if (isPrimary && !_sessions.isEmpty()) {
// kill all the others also // kill all the others also
for (SessionParams sp : _sessions.values()) { for (SessionParams sp : _sessions.values()) {
_manager.unregisterSession(id, sp.dest); if (_log.shouldLog(Log.INFO))
_log.info("Destroying remaining client subsession " + sp.sessionId);
_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().unpublish(ls);
_context.tunnelManager().removeAlias(sp.dest);
} }
} }
} }

View File

@ -220,14 +220,14 @@ class ClientManager {
* Remove all sessions for this runner. * Remove all sessions for this runner.
*/ */
public void unregisterConnection(ClientConnectionRunner runner) { public void unregisterConnection(ClientConnectionRunner runner) {
if (_log.shouldLog(Log.WARN))
_log.warn("Unregistering (dropping) a client connection");
synchronized (_pendingRunners) { synchronized (_pendingRunners) {
_pendingRunners.remove(runner); _pendingRunners.remove(runner);
} }
List<SessionId> ids = runner.getSessionIds(); List<SessionId> ids = runner.getSessionIds();
List<Destination> dests = runner.getDestinations(); List<Destination> dests = runner.getDestinations();
if (_log.shouldLog(Log.WARN))
_log.warn("Unregistering (dropping) a client connection with ids: " + ids);
synchronized (_runners) { synchronized (_runners) {
for (SessionId id : ids) { for (SessionId id : ids) {
_runnerSessionIds.remove(id); _runnerSessionIds.remove(id);

View File

@ -426,8 +426,6 @@ class ClientMessageEventListener implements I2CPMessageReader.I2CPMessageEventLi
if (left <= 0) { if (left <= 0) {
_runner.stopRunning(); _runner.stopRunning();
} else { } else {
if (cfg != null)
_context.tunnelManager().removeAlias(cfg.getDestination());
if (_log.shouldLog(Log.INFO)) if (_log.shouldLog(Log.INFO))
_log.info("Still " + left + " sessions left"); _log.info("Still " + left + " sessions left");
} }