Skip to content

Commit

Permalink
Merge pull request #1933 from fengxx/feature/removecomputer
Browse files Browse the repository at this point in the history
[FIXED JENKINS-31768] - Remove monitor lock from setNumberExecutors to avoid deadlock
  • Loading branch information
stephenc committed Oct 17, 2016
2 parents 2311ae8 + 4c6ed07 commit 430736a
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion core/src/main/java/hudson/model/Computer.java
Expand Up @@ -861,7 +861,20 @@ protected void kill() {
protected void onRemoved(){
}

private synchronized void setNumExecutors(int n) {
/**
* Calling path, *means protected by Queue.withLock
*
* Computer.doConfigSubmit -> Computer.replaceBy ->Jenkins.setNodes* ->Computer.setNode
* AbstractCIBase.updateComputerList->Computer.inflictMortalWound*
* AbstractCIBase.updateComputerList->AbstractCIBase.updateComputer* ->Computer.setNode
* AbstractCIBase.updateComputerList->AbstractCIBase.killComputer->Computer.kill
* Computer.constructor->Computer.setNode
* Computer.kill is called after numExecutors set to zero(Computer.inflictMortalWound) so not need the Queue.lock
*
* @param number of executors
*/
@GuardedBy("hudson.model.Queue.lock")
private void setNumExecutors(int n) {
this.numExecutors = n;
final int diff = executors.size()-n;

Expand Down

0 comments on commit 430736a

Please sign in to comment.