From 24408ed660d3e36fa9e31fec93d6d767042e77d7 Mon Sep 17 00:00:00 2001 From: mindless Date: Mon, 12 Jul 2010 22:26:04 +0000 Subject: [PATCH] [FIXED HUDSON-6649] doQuietDown was sychronized, so safeRestart (calling doQuietDown in blocking mode since 1.361) was locking Hudson object until all jobs complete! Now synchronize just to set isQuietingDown flag, but not while blocking. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@32805 71c3de6d-444a-0410-be80-ed276b4c234a --- core/src/main/java/hudson/model/Hudson.java | 31 ++++++--------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/core/src/main/java/hudson/model/Hudson.java b/core/src/main/java/hudson/model/Hudson.java index e171aa16ba..245b6e805c 100644 --- a/core/src/main/java/hudson/model/Hudson.java +++ b/core/src/main/java/hudson/model/Hudson.java @@ -2473,32 +2473,19 @@ public final class Hudson extends Node implements ItemGroup, Stapl } @CLIMethod(name="quiet-down") - public synchronized HttpRedirect doQuietDown( + public HttpRedirect doQuietDown( @Option(name="-block",usage="Block until the system really quiets down and no builds are running") @QueryParameter boolean block, @Option(name="-timeout",usage="If non-zero, only block up to the specified number of milliseconds") @QueryParameter int timeout) throws InterruptedException { - checkPermission(ADMINISTER); - isQuietingDown = true; + synchronized (this) { + checkPermission(ADMINISTER); + isQuietingDown = true; + } if (block) { - LOGGER.info("Entering the blocking quiet down mode"); - long start = System.currentTimeMillis(); - int cnt=0; - while (true) { - if (!isQuietingDown) { - LOGGER.info("Quiet mode cancelled"); - break; - } - if (overallLoad.computeTotalExecutors() <= overallLoad.computeIdleExecutors()) {// should be really == but be defensive - LOGGER.info("System became fully quiet"); - break; - } - if (timeout>0 && start+timeout<=System.currentTimeMillis()) { - LOGGER.info("Quiet mode time out after "+timeout+"ms"); - break; - } - + if (timeout > 0) timeout += System.currentTimeMillis(); + while (isQuietingDown + && (overallLoad.computeTotalExecutors() > overallLoad.computeIdleExecutors()) + && (timeout <= 0 || System.currentTimeMillis() < timeout)) { Thread.sleep(1000); - if (((cnt++)%60)==0) - LOGGER.info("Waiting for all the jobs to finish. Total="+overallLoad.computeTotalExecutors()+" idle="+overallLoad.computeIdleExecutors()); } } return new HttpRedirect(".");