2004-10-05 jrandom

* Display how much time is left before the graceful shutdown is complete.
    * Debug some improperly failed messages on timeout or disconnection.
This commit is contained in:
jrandom
2004-10-05 19:21:47 +00:00
committed by zzz
parent 756af9c699
commit 98c780415b
8 changed files with 76 additions and 4 deletions

View File

@@ -660,6 +660,14 @@ public class Router {
public boolean gracefulShutdownInProgress() {
return (null != _config.getProperty(PROP_SHUTDOWN_IN_PROGRESS));
}
/** How long until the graceful shutdown will kill us? */
public long getShutdownTimeRemaining() {
long exp = _context.tunnelManager().getLastParticipatingExpiration();
if (exp < 0)
return -1;
else
return exp - _context.clock().now();
}
/**
* Simple thread that sits and waits forever, managing the

View File

@@ -67,4 +67,7 @@ public interface TunnelManagerFacade extends Service {
public int getFreeTunnelCount();
/** how many outbound tunnels do we have available? */
public int getOutboundTunnelCount();
/** When does the last tunnel we are participating in expire? */
public long getLastParticipatingExpiration();
}

View File

@@ -110,7 +110,8 @@ public class TCPConnection {
if (_socket != null) try { _socket.close(); } catch (IOException ioe) {}
List msgs = clearPendingMessages();
for (int i = 0; i < msgs.size(); i++) {
OutNetMessage msg = (OutNetMessage)msgs.get(0);
OutNetMessage msg = (OutNetMessage)msgs.get(i);
msg.timestamp("closeConnection");
_transport.afterSend(msg, false, true, -1);
}
_context.profileManager().commErrorOccurred(_ident.getHash());

View File

@@ -274,7 +274,9 @@ public class TCPTransport extends TransportImpl {
_context.shitlist().shitlistRouter(con.getAttemptedPeer(), "Changed identities");
if (changedMsgs != null) {
for (int i = 0; i < changedMsgs.size(); i++) {
afterSend((OutNetMessage)changedMsgs.get(i), false, false, 0);
OutNetMessage cur = (OutNetMessage)changedMsgs.get(i);
cur.timestamp("changedIdents");
afterSend(cur, false, false, 0);
}
}
}
@@ -587,6 +589,7 @@ public class TCPTransport extends TransportImpl {
_context.netDb().fail(peer);
for (int i = 0; i < msgs.size(); i++) {
OutNetMessage cur = (OutNetMessage)msgs.get(i);
cur.timestamp("no TCP addresses");
afterSend(cur, false, false, 0);
}
continue;
@@ -600,6 +603,7 @@ public class TCPTransport extends TransportImpl {
_context.netDb().fail(peer);
for (int i = 0; i < msgs.size(); i++) {
OutNetMessage cur = (OutNetMessage)msgs.get(i);
cur.timestamp("invalid addresses");
afterSend(cur, false, false, 0);
}
continue; // invalid
@@ -613,6 +617,7 @@ public class TCPTransport extends TransportImpl {
_context.netDb().fail(peer);
for (int i = 0; i < msgs.size(); i++) {
OutNetMessage cur = (OutNetMessage)msgs.get(i);
cur.timestamp("points at us");
afterSend(cur, false, false, 0);
}
continue;
@@ -624,6 +629,7 @@ public class TCPTransport extends TransportImpl {
_context.netDb().fail(peer);
for (int i = 0; i < msgs.size(); i++) {
OutNetMessage cur = (OutNetMessage)msgs.get(i);
cur.timestamp("points at our ip");
afterSend(cur, false, false, 0);
}
continue;
@@ -637,6 +643,7 @@ public class TCPTransport extends TransportImpl {
_context.netDb().fail(peer);
for (int i = 0; i < msgs.size(); i++) {
OutNetMessage cur = (OutNetMessage)msgs.get(i);
cur.timestamp("points at an illegal address");
afterSend(cur, false, false, 0);
}
continue;
@@ -675,6 +682,7 @@ public class TCPTransport extends TransportImpl {
// connectionEstablished clears them otherwise)
for (int i = 0; i < msgs.size(); i++) {
OutNetMessage msg = (OutNetMessage)msgs.get(i);
msg.timestamp("establishmentComplete(failed)");
afterSend(msg, false);
}
}

View File

@@ -234,5 +234,15 @@ public class PoolingTunnelManagerFacade implements TunnelManagerFacade {
if (_pool != null)
_pool.renderStatusHTML(out);
}
public long getLastParticipatingExpiration() {
long last = -1;
for (Iterator iter = _pool.getParticipatingTunnels().iterator(); iter.hasNext(); ) {
TunnelId id = (TunnelId)iter.next();
TunnelInfo info = _pool.getParticipatingTunnel(id);
if ( (info != null) && (info.getSettings().getExpiration() > last) )
last = info.getSettings().getExpiration();
}
return last;
}
}