forked from I2P_Developers/i2p.i2p
NetDB: Improve handling of deferred search result jobs
This commit is contained in:
@ -232,6 +232,7 @@ class FloodOnlySearchJob extends FloodSearchJob {
|
||||
synchronized (this) {
|
||||
if (_dead) return;
|
||||
_dead = true;
|
||||
super.success();
|
||||
}
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
_log.info(getJobId() + ": Floodfill search for " + _key + " successful");
|
||||
|
@ -33,6 +33,7 @@ public class FloodSearchJob extends JobImpl {
|
||||
protected final AtomicInteger _lookupsRemaining = new AtomicInteger();
|
||||
protected volatile boolean _dead;
|
||||
protected final long _created;
|
||||
protected boolean _success;
|
||||
|
||||
/**
|
||||
* @param onFind may be null
|
||||
@ -69,6 +70,7 @@ public class FloodSearchJob extends JobImpl {
|
||||
* @param isLease ignored
|
||||
*/
|
||||
void addDeferred(Job onFind, Job onFailed, long timeoutMs, boolean isLease) {
|
||||
boolean success;
|
||||
synchronized (this) {
|
||||
if (!_dead) {
|
||||
if (onFind != null)
|
||||
@ -77,8 +79,12 @@ public class FloodSearchJob extends JobImpl {
|
||||
_onFailed.add(onFailed);
|
||||
return;
|
||||
}
|
||||
success = _success;
|
||||
}
|
||||
// outside synch to avoid deadlock with job queue
|
||||
if (success && onFind != null)
|
||||
getContext().jobQueue().addJob(onFind);
|
||||
else if (!success && onFailed != null)
|
||||
getContext().jobQueue().addJob(onFailed);
|
||||
}
|
||||
|
||||
@ -193,8 +199,11 @@ public class FloodSearchJob extends JobImpl {
|
||||
* Deprecated, unused, see FOSJ override
|
||||
*/
|
||||
void success() {
|
||||
throw new UnsupportedOperationException("use override");
|
||||
synchronized(this) {
|
||||
_success = true;
|
||||
}
|
||||
/****
|
||||
throw new UnsupportedOperationException("use override");
|
||||
if (_dead) return;
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
_log.info(getJobId() + ": Floodfill search for " + _key.toBase64() + " successful");
|
||||
|
@ -587,6 +587,7 @@ class IterativeSearchJob extends FloodSearchJob {
|
||||
synchronized(this) {
|
||||
if (_dead) return;
|
||||
_dead = true;
|
||||
_success = true;
|
||||
tries = _unheardFrom.size() + _failedPeers.size();
|
||||
if (_unheardFrom.size() == 1) {
|
||||
peer = _unheardFrom.iterator().next();
|
||||
|
Reference in New Issue
Block a user