Skip to content
Permalink
Browse files

Merge pull request #1730 from stephenc/jenkins-28690

[FIXED JENKINS-28690] Deadlock in hudson.model.Executor
  • Loading branch information...
stephenc committed Jun 10, 2015
2 parents f628e39 + ddb0a47 commit 4540ba71b5fac5eede500878993eb3e5b165979d
Showing with 9 additions and 2 deletions.
  1. +9 −2 core/src/main/java/hudson/model/Executor.java
@@ -205,15 +205,22 @@ private void interrupt(Result result, boolean forShutdown, CauseOfInterruption..
}

public Result abortResult() {
lock.readLock().lock();
// this method is almost always called as a result of the current thread being interrupted
// as a result we need to clean the interrupt flag so that the lock's lock method doesn't
// get confused and think it was interrupted while awaiting the lock
Thread.interrupted();
// we need to use a write lock as we may be repeatedly interrupted while processing and
// we need the same lock as used in void interrupt(Result,boolean,CauseOfInterruption...)
// JENKINS-28690
lock.writeLock().lock();
try {
Result r = interruptStatus;
if (r == null) r =
Result.ABORTED; // this is when we programmatically throw InterruptedException instead of calling the interrupt method.

return r;
} finally {
lock.readLock().unlock();
lock.writeLock().unlock();
}
}

0 comments on commit 4540ba7

Please sign in to comment.
You can’t perform that action at this time.