Permalink
Browse files

Logging and always grab() if it e.g. fails.

  • Loading branch information...
1 parent 3d9c609 commit 47edfe611a1f088b51fccb36d3e7710e28c3d2b8 @toad toad committed Jan 29, 2011
Showing with 9 additions and 3 deletions.
  1. +9 −3 src/freenet/node/PeerNode.java
@@ -4801,7 +4801,10 @@ void onFailed(PeerNode peer, boolean reallyFailed) {
public PeerNode waitForAny(long maxWait) {
PeerNode[] all;
synchronized(this) {
- if(shouldGrab()) return grab();
+ if(shouldGrab()) {
+ if(logMINOR) Logger.minor(this, "Already matched on "+this);
+ return grab();
+ }
all = waitingFor.toArray(new PeerNode[waitingFor.size()]);
}
// Double-check before blocking, prevent race condition.
@@ -4812,16 +4815,19 @@ public PeerNode waitForAny(long maxWait) {
PeerNode[] unreg;
PeerNode other = null;
synchronized(this) {
+ if(logMINOR) Logger.minor(this, "tryRouteTo() succeeded to "+p+" on "+this+" with "+accept+" - checking whether we have already accepted.");
unreg = innerOnWaited(p, accept);
if(unreg == null) {
+ // Recover from race condition.
if(shouldGrab()) other = grab();
- } else {
+ }
+ if(other == null) {
+ if(logMINOR) Logger.minor(this, "Trying the original tryRouteTo() on "+this);
// Having set the acceptedBy etc, clear it now.
grab();
}
}
if(other != null) {
- // Recover from race condition.
Logger.normal(this, "Race condition: tryRouteTo() succeeded on "+p.shortToString()+" but already matched on "+other.shortToString()+" on "+this);
tag.removeRoutingTo(p);
return other;

0 comments on commit 47edfe6

Please sign in to comment.