forked from I2P_Developers/i2p.i2p
2004-10-02 jrandom
* Assure that we quickly fail messages bound for shitlisted peers. * Address a race on startup where the first peer contacted could hang the router (thanks Romster!) * Only whine about an intermittent inability to query the time server once
This commit is contained in:
@ -115,7 +115,7 @@ public class NtpClient {
|
|||||||
//System.out.println("host: " + serverName + " rtt: " + roundTripDelay + " offset: " + localClockOffset + " seconds");
|
//System.out.println("host: " + serverName + " rtt: " + roundTripDelay + " offset: " + localClockOffset + " seconds");
|
||||||
return (long)(System.currentTimeMillis() + localClockOffset*1000);
|
return (long)(System.currentTimeMillis() + localClockOffset*1000);
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
ioe.printStackTrace();
|
//ioe.printStackTrace();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,6 +100,7 @@ public class Timestamper implements Runnable {
|
|||||||
|
|
||||||
if (_log.shouldLog(Log.INFO))
|
if (_log.shouldLog(Log.INFO))
|
||||||
_log.info("Starting up timestamper");
|
_log.info("Starting up timestamper");
|
||||||
|
boolean alreadyBitched = false;
|
||||||
try {
|
try {
|
||||||
while (true) {
|
while (true) {
|
||||||
updateConfig();
|
updateConfig();
|
||||||
@ -118,7 +119,9 @@ public class Timestamper implements Runnable {
|
|||||||
_log.debug("Stamp time");
|
_log.debug("Stamp time");
|
||||||
stampTime(now);
|
stampTime(now);
|
||||||
} catch (IllegalArgumentException iae) {
|
} catch (IllegalArgumentException iae) {
|
||||||
_log.log(Log.CRIT, "Unable to reach any of the NTP servers - network disconnected?");
|
if (!alreadyBitched)
|
||||||
|
_log.log(Log.CRIT, "Unable to reach any of the NTP servers - network disconnected?");
|
||||||
|
alreadyBitched = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try { Thread.sleep(_queryFrequency); } catch (InterruptedException ie) {}
|
try { Thread.sleep(_queryFrequency); } catch (InterruptedException ie) {}
|
||||||
|
@ -1,4 +1,10 @@
|
|||||||
$Id: history.txt,v 1.28 2004/10/01 12:23:00 jrandom Exp $
|
$Id: history.txt,v 1.29 2004/10/02 07:31:16 jrandom Exp $
|
||||||
|
|
||||||
|
2004-10-02 jrandom
|
||||||
|
* Assure that we quickly fail messages bound for shitlisted peers.
|
||||||
|
* Address a race on startup where the first peer contacted could hang the
|
||||||
|
router (thanks Romster!)
|
||||||
|
* Only whine about an intermittent inability to query the time server once
|
||||||
|
|
||||||
2004-10-02 jrandom
|
2004-10-02 jrandom
|
||||||
* Command line utility to verify a peer's reachability - simply run
|
* Command line utility to verify a peer's reachability - simply run
|
||||||
|
@ -21,7 +21,6 @@ import java.util.Set;
|
|||||||
|
|
||||||
import net.i2p.data.DataFormatException;
|
import net.i2p.data.DataFormatException;
|
||||||
import net.i2p.data.DataHelper;
|
import net.i2p.data.DataHelper;
|
||||||
import net.i2p.data.Hash;
|
|
||||||
import net.i2p.data.RouterInfo;
|
import net.i2p.data.RouterInfo;
|
||||||
import net.i2p.data.i2np.I2NPMessage;
|
import net.i2p.data.i2np.I2NPMessage;
|
||||||
import net.i2p.util.Log;
|
import net.i2p.util.Log;
|
||||||
@ -35,7 +34,6 @@ public class OutNetMessage {
|
|||||||
private Log _log;
|
private Log _log;
|
||||||
private RouterContext _context;
|
private RouterContext _context;
|
||||||
private RouterInfo _target;
|
private RouterInfo _target;
|
||||||
private Hash _targetHash;
|
|
||||||
private I2NPMessage _message;
|
private I2NPMessage _message;
|
||||||
/** cached message class name, for use after we discard the message */
|
/** cached message class name, for use after we discard the message */
|
||||||
private String _messageType;
|
private String _messageType;
|
||||||
@ -123,8 +121,6 @@ public class OutNetMessage {
|
|||||||
*/
|
*/
|
||||||
public RouterInfo getTarget() { return _target; }
|
public RouterInfo getTarget() { return _target; }
|
||||||
public void setTarget(RouterInfo target) { _target = target; }
|
public void setTarget(RouterInfo target) { _target = target; }
|
||||||
public Hash getTargetHash() { return _targetHash; }
|
|
||||||
public void setTargetHash(Hash target) { _targetHash = target; }
|
|
||||||
/**
|
/**
|
||||||
* Specifies the message to be sent
|
* Specifies the message to be sent
|
||||||
*
|
*
|
||||||
|
@ -15,9 +15,9 @@ import net.i2p.CoreVersion;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class RouterVersion {
|
public class RouterVersion {
|
||||||
public final static String ID = "$Revision: 1.38 $ $Date: 2004/10/01 12:23:00 $";
|
public final static String ID = "$Revision: 1.39 $ $Date: 2004/10/02 07:31:15 $";
|
||||||
public final static String VERSION = "0.4.1.1";
|
public final static String VERSION = "0.4.1.1";
|
||||||
public final static long BUILD = 4;
|
public final static long BUILD = 5;
|
||||||
public static void main(String args[]) {
|
public static void main(String args[]) {
|
||||||
System.out.println("I2P Router version: " + VERSION);
|
System.out.println("I2P Router version: " + VERSION);
|
||||||
System.out.println("Router ID: " + RouterVersion.ID);
|
System.out.println("Router ID: " + RouterVersion.ID);
|
||||||
|
@ -559,31 +559,11 @@ public class SendTunnelMessageJob extends JobImpl {
|
|||||||
outM.setOnSendJob(_onSend);
|
outM.setOnSendJob(_onSend);
|
||||||
outM.setPriority(_priority);
|
outM.setPriority(_priority);
|
||||||
outM.setReplySelector(_selector);
|
outM.setReplySelector(_selector);
|
||||||
if (_destRouter != null)
|
outM.setTarget(getContext().netDb().lookupRouterInfoLocally(_destRouter));
|
||||||
outM.setTargetHash(_destRouter);
|
|
||||||
else
|
|
||||||
outM.setTargetHash(getContext().routerHash());
|
|
||||||
getContext().messageRegistry().registerPending(outM);
|
getContext().messageRegistry().registerPending(outM);
|
||||||
_onFailure = new FakeOnFailJob(getContext(), outM, _onFailure);
|
|
||||||
// we dont really need the data
|
// we dont really need the data
|
||||||
outM.discardData();
|
outM.discardData();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class FakeOnFailJob extends JobImpl {
|
|
||||||
private OutNetMessage _fakeMessage;
|
|
||||||
private Job _realOnFailJob;
|
|
||||||
public FakeOnFailJob(RouterContext ctx, OutNetMessage msg, Job realOnFailJob) {
|
|
||||||
super(ctx);
|
|
||||||
_fakeMessage = msg;
|
|
||||||
_realOnFailJob = realOnFailJob;
|
|
||||||
}
|
|
||||||
public String getName() { return "Fake message failure job"; }
|
|
||||||
public void runJob() {
|
|
||||||
getContext().messageRegistry().unregisterPending(_fakeMessage);
|
|
||||||
if (_realOnFailJob != null)
|
|
||||||
getContext().jobQueue().addJob(_realOnFailJob);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() { return "Send Tunnel Message"; }
|
public String getName() { return "Send Tunnel Message"; }
|
||||||
}
|
}
|
||||||
|
@ -38,14 +38,16 @@ public class GetBidsJob extends JobImpl {
|
|||||||
public String getName() { return "Fetch bids for a message to be delivered"; }
|
public String getName() { return "Fetch bids for a message to be delivered"; }
|
||||||
public void runJob() {
|
public void runJob() {
|
||||||
Hash to = _msg.getTarget().getIdentity().getHash();
|
Hash to = _msg.getTarget().getIdentity().getHash();
|
||||||
|
|
||||||
if (getContext().shitlist().isShitlisted(to)) {
|
if (getContext().shitlist().isShitlisted(to)) {
|
||||||
_log.warn("Attempt to send a message to a shitlisted peer - " + to);
|
_log.warn("Attempt to send a message to a shitlisted peer - " + to);
|
||||||
|
getContext().messageRegistry().peerFailed(to);
|
||||||
fail();
|
fail();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Hash us = getContext().routerHash();
|
Hash us = getContext().routerHash();
|
||||||
if (_msg.getTarget().getIdentity().getHash().equals(us)) {
|
if (to.equals(us)) {
|
||||||
_log.error("wtf, send a message to ourselves? nuh uh. msg = " + _msg, getAddedBy());
|
_log.error("wtf, send a message to ourselves? nuh uh. msg = " + _msg, getAddedBy());
|
||||||
fail();
|
fail();
|
||||||
return;
|
return;
|
||||||
@ -54,11 +56,8 @@ public class GetBidsJob extends JobImpl {
|
|||||||
List bids = _facade.getBids(_msg);
|
List bids = _facade.getBids(_msg);
|
||||||
if (bids.size() <= 0) {
|
if (bids.size() <= 0) {
|
||||||
_log.warn("No bids available for the message " + _msg);
|
_log.warn("No bids available for the message " + _msg);
|
||||||
Hash target = _msg.getTargetHash();
|
getContext().shitlist().shitlistRouter(to, "No bids");
|
||||||
if (target == null)
|
getContext().netDb().fail(to);
|
||||||
target = _msg.getTarget().getIdentity().getHash();
|
|
||||||
getContext().shitlist().shitlistRouter(target, "No bids");
|
|
||||||
getContext().netDb().fail(target);
|
|
||||||
fail();
|
fail();
|
||||||
} else {
|
} else {
|
||||||
TransportBid bid = (TransportBid)bids.get(0);
|
TransportBid bid = (TransportBid)bids.get(0);
|
||||||
@ -79,10 +78,7 @@ public class GetBidsJob extends JobImpl {
|
|||||||
getContext().messageRegistry().unregisterPending(_msg);
|
getContext().messageRegistry().unregisterPending(_msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_msg.getTargetHash() != null)
|
getContext().profileManager().messageFailed(_msg.getTarget().getIdentity().getHash());
|
||||||
getContext().profileManager().messageFailed(_msg.getTargetHash());
|
|
||||||
else
|
|
||||||
getContext().profileManager().messageFailed(_msg.getTarget().getIdentity().getHash());
|
|
||||||
|
|
||||||
_msg.discardData();
|
_msg.discardData();
|
||||||
}
|
}
|
||||||
|
@ -279,14 +279,24 @@ public class OutboundMessageRegistry {
|
|||||||
|
|
||||||
public void peerFailed(Hash peer) {
|
public void peerFailed(Hash peer) {
|
||||||
List failed = null;
|
List failed = null;
|
||||||
|
int numFailed = 0;
|
||||||
synchronized (_pendingMessages) {
|
synchronized (_pendingMessages) {
|
||||||
for (Iterator iter = _pendingMessages.values().iterator(); iter.hasNext(); ) {
|
for (Iterator iter = _pendingMessages.values().iterator(); iter.hasNext(); ) {
|
||||||
OutNetMessage msg = (OutNetMessage)iter.next();
|
OutNetMessage msg = (OutNetMessage)iter.next();
|
||||||
if ( (msg.getTargetHash() != null) && (msg.getTargetHash().equals(peer)) ) {
|
if (msg.getTarget() != null) {
|
||||||
if (failed == null)
|
Hash to = msg.getTarget().getIdentity().calculateHash();
|
||||||
failed = new ArrayList(4);
|
if (to.equals(peer)) {
|
||||||
failed.add(msg);
|
if (failed == null)
|
||||||
iter.remove();
|
failed = new ArrayList(4);
|
||||||
|
failed.add(msg);
|
||||||
|
iter.remove();
|
||||||
|
numFailed++;
|
||||||
|
} else {
|
||||||
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
|
_log.debug("Peer failed: " + peer.toBase64().substring(0,6)
|
||||||
|
+ " but not killing a message to "
|
||||||
|
+ to.toBase64().substring(0,6));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -299,6 +309,8 @@ public class OutboundMessageRegistry {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_log.shouldLog(Log.WARN))
|
||||||
|
_log.warn("Peer failed: " + peer.toBase64().substring(0,6) + " killing " + numFailed);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renderStatusHTML(Writer out) throws IOException {
|
public void renderStatusHTML(Writer out) throws IOException {
|
||||||
@ -314,6 +326,7 @@ public class OutboundMessageRegistry {
|
|||||||
OutNetMessage msg = (OutNetMessage)msgs.get(exp);
|
OutNetMessage msg = (OutNetMessage)msgs.get(exp);
|
||||||
buf.append("<li>").append(msg.getMessageType());
|
buf.append("<li>").append(msg.getMessageType());
|
||||||
buf.append(": expiring on ").append(new Date(exp.longValue()));
|
buf.append(": expiring on ").append(new Date(exp.longValue()));
|
||||||
|
buf.append(" targetting ").append(msg.getTarget().getIdentity().getHash());
|
||||||
if (msg.getReplySelector() != null)
|
if (msg.getReplySelector() != null)
|
||||||
buf.append(" with reply selector ").append(msg.getReplySelector().toString());
|
buf.append(" with reply selector ").append(msg.getReplySelector().toString());
|
||||||
else
|
else
|
||||||
|
@ -168,6 +168,9 @@ public class TCPTransport extends TransportImpl {
|
|||||||
// _log.debug("Outbound message ready: " + msg);
|
// _log.debug("Outbound message ready: " + msg);
|
||||||
|
|
||||||
if (msg != null) {
|
if (msg != null) {
|
||||||
|
if (msg.getTarget() == null)
|
||||||
|
throw new IllegalStateException("Null target for a ready message?");
|
||||||
|
|
||||||
TCPConnection con = null;
|
TCPConnection con = null;
|
||||||
boolean newPeer = false;
|
boolean newPeer = false;
|
||||||
synchronized (_connectionLock) {
|
synchronized (_connectionLock) {
|
||||||
|
@ -149,6 +149,7 @@ public class PoolingTunnelManagerFacade implements TunnelManagerFacade {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void peerFailed(Hash peer) {
|
public void peerFailed(Hash peer) {
|
||||||
|
if (_pool == null) return; // just initialized
|
||||||
int numFailed = 0;
|
int numFailed = 0;
|
||||||
boolean shouldKill = false;
|
boolean shouldKill = false;
|
||||||
for (Iterator iter = _pool.getManagedTunnelIds().iterator(); iter.hasNext(); ) {
|
for (Iterator iter = _pool.getManagedTunnelIds().iterator(); iter.hasNext(); ) {
|
||||||
|
Reference in New Issue
Block a user