Opened 19 months ago

Last modified 18 months ago

#2382 closed enhancement

Fix isUnreachable() and wasUnreachable() in TransportImpl.java — at Initial Version

Reported by: jogger Owned by: zzz
Priority: minor Milestone: 0.9.39
Component: router/transport Version: 0.9.37
Keywords: Cc:
Parent Tickets: Sensitive: no

Description

The following code takes the now() out of the critical path. Part of the solution for 2355.

public boolean isUnreachable(Hash peer) {

long now = _context.clock().now();

synchronized (_unreachableEntries) {

Long when = _unreachableEntries.get(peer);
if (when == null) return false;

if (when.longValue() + UNREACHABLE_PERIOD < now) {

if (when.longValue() + UNREACHABLE_PERIOD < _context.clock().now()) {

_unreachableEntries.remove(peer);
return false;

} else {

return true;

}

}

}

public boolean wasUnreachable(Hash peer) {

long now = _context.clock().now();

synchronized (_wasUnreachableEntries) {

Long when = _wasUnreachableEntries.get(peer);
if (when != null) {

if (when.longValue() + WAS_UNREACHABLE_PERIOD < now) {

if (when.longValue() + WAS_UNREACHABLE_PERIOD < _context.clock().now()) {

_unreachableEntries.remove(peer);
return false;

} else {

return true;

}

}

}
RouterInfo? ri = _context.netDb().lookupRouterInfoLocally(peer);
if (ri == null)

return false;

return null == ri.getTargetAddress(this.getStyle());

}

Subtickets

Change History (0)

Note: See TracTickets for help on using tickets.