Transport: Don't shitlist a peer if we are at our connection limit

This commit is contained in:
zzz
2009-01-05 15:16:14 +00:00
parent 7271289c1f
commit 8faeaaa1ae
5 changed files with 14 additions and 4 deletions

View File

@ -66,7 +66,8 @@ public class GetBidsJob extends JobImpl {
int failedCount = msg.getFailedTransports().size();
if (failedCount == 0) {
context.statManager().addRateData("transport.bidFailNoTransports", msg.getLifetime(), 0);
context.shitlist().shitlistRouter(to, "We share no common transports with them");
// This used to be "no common transports" but it is almost always no transports at all
context.shitlist().shitlistRouter(to, "No transports (hidden or starting up?)");
} else if (failedCount >= facade.getTransportCount()) {
context.statManager().addRateData("transport.bidFailAllTransports", msg.getLifetime(), 0);
// fail after all transports were unsuccessful

View File

@ -23,6 +23,8 @@ public class TransportBid {
private long _bidExpiration;
private Transport _transport;
public static final int TRANSIENT_FAIL = 999999;
public TransportBid() {
setLatencyMs(-1);
setBandwidthBytes(-1);

View File

@ -301,7 +301,10 @@ public class TransportManager implements TransportEventListener {
// to us via TCP, send via TCP)
TransportBid bid = t.bid(msg.getTarget(), msg.getMessageSize());
if (bid != null) {
if ( (rv == null) || (rv.getLatencyMs() > bid.getLatencyMs()) )
if (bid.getLatencyMs() == bid.TRANSIENT_FAIL)
// this keeps GetBids() from shitlisting for "no common transports"
msg.transportFailed(t.getStyle());
else if ( (rv == null) || (rv.getLatencyMs() > bid.getLatencyMs()) )
rv = bid;
if (_log.shouldLog(Log.DEBUG))
_log.debug("Transport " + t.getStyle() + " bid: " + bid + " currently winning? " + (rv == bid)

View File

@ -36,6 +36,7 @@ public class NTCPTransport extends TransportImpl {
private Log _log;
private SharedBid _fastBid;
private SharedBid _slowBid;
private SharedBid _transientFail;
private Object _conLock;
private Map _conByIdent;
private NTCPAddress _myAddress;
@ -131,6 +132,7 @@ public class NTCPTransport extends TransportImpl {
_fastBid = new SharedBid(25); // best
_slowBid = new SharedBid(70); // better than ssu unestablished, but not better than ssu established
_transientFail = new SharedBid(TransportBid.TRANSIENT_FAIL);
}
void inboundEstablished(NTCPConnection con) {
@ -289,7 +291,7 @@ public class NTCPTransport extends TransportImpl {
if (!allowConnection()) {
if (_log.shouldLog(Log.WARN))
_log.warn("no bid when trying to send to " + toAddress.getIdentity().calculateHash().toBase64() + ", max connection limit reached");
return null;
return _transientFail;
}
//if ( (_myAddress != null) && (_myAddress.equals(addr)) )

View File

@ -86,6 +86,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
private TransportBid _fastPreferredBid;
/** shared slow bid for unconnected peers when we want to always prefer UDP */
private TransportBid _slowPreferredBid;
private TransportBid _transientFail;
/** list of RemoteHostId for peers whose packets we want to drop outright */
private List _dropList;
@ -157,6 +158,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
_fastPreferredBid = new SharedBid(15);
_slowPreferredBid = new SharedBid(20);
_slowestBid = new SharedBid(1000);
_transientFail = new SharedBid(TransportBid.TRANSIENT_FAIL);
_fragments = new OutboundMessageFragments(_context, this, _activeThrottle);
_inboundFragments = new InboundMessageFragments(_context, _fragments, this);
@ -891,7 +893,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
}
}
if (!allowConnection())
return null;
return _transientFail;
if (_log.shouldLog(Log.DEBUG))
_log.debug("bidding on a message to an unestablished peer: " + to.toBase64());