Skip to content
Permalink
Browse files

Merge pull request #1933 from fengxx/feature/removecomputer

[FIXED JENKINS-31768] - Remove monitor lock from setNumberExecutors to avoid deadlock
  • Loading branch information
stephenc committed Oct 17, 2016
2 parents 2311ae8 + 4c6ed07 commit 430736ad619c52bde438c63f5c81e50fedd63fdb
Showing with 14 additions and 1 deletion.
  1. +14 −1 core/src/main/java/hudson/model/Computer.java
@@ -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;

0 comments on commit 430736a

Please sign in to comment.