[Swift-commit] cog r3490

swift at ci.uchicago.edu swift at ci.uchicago.edu
Sat Oct 27 18:00:39 CDT 2012


------------------------------------------------------------------------
r3490 | hategan | 2012-10-27 17:57:34 -0500 (Sat, 27 Oct 2012) | 1 line

fixed deadlock in shutdown
------------------------------------------------------------------------
Index: modules/provider-coaster/src/org/globus/cog/abstraction/coaster/service/job/manager/Block.java
===================================================================
--- modules/provider-coaster/src/org/globus/cog/abstraction/coaster/service/job/manager/Block.java	(revision 3489)
+++ modules/provider-coaster/src/org/globus/cog/abstraction/coaster/service/job/manager/Block.java	(working copy)
@@ -256,54 +256,57 @@
     }
 
     public void shutdown(boolean now) {
+        List<Cpu> cpusToShutDown;
         synchronized (cpus) {
             if (shutdown) {
                 return;
             }
-            logger.info("Shutting down block " + this);
-            bqp.getRLogger().log("BLOCK_SHUTDOWN id=" + getId());
             shutdown = true;
-            long busyTotal = 0;
-            long idleTotal = 0;
-            int count = 0;
-            if (running) {
-                for (Cpu cpu : cpus) {
-                    idleTotal = cpu.idleTime;
-                    busyTotal = cpu.busyTime;
-                    if (!failed) {
-                        cpu.shutdown();
-                    }
-                    count++;
+            cpusToShutDown = new ArrayList<Cpu>(cpus);
+            cpus.clear();
+        }
+        logger.info("Shutting down block " + this);
+        bqp.getRLogger().log("BLOCK_SHUTDOWN id=" + getId());
+        
+        long busyTotal = 0;
+        long idleTotal = 0;
+        int count = 0;
+        if (running) {
+            for (Cpu cpu : cpusToShutDown) {
+                idleTotal = cpu.idleTime;
+                busyTotal = cpu.busyTime;
+                if (!failed) {
+                    cpu.shutdown();
                 }
-				if (!failed) {
-					if (count < workers || now) {
-					    if (logger.isInfoEnabled()) {
-					        logger.info("Adding short shutdown watchdog: count = " + 
-					            count + ", workers = " + workers + ", now = " + now);
-					    }
-	                    addForcedShutdownWatchdog(100);
-    	            }
-					else {
-					    if (logger.isInfoEnabled()) {
-					        logger.info("Adding normal shutdown watchdog");
-					    }
-	   					addForcedShutdownWatchdog(SHUTDOWN_WATCHDOG_DELAY);
-					}
+                count++;
+            }
+			if (!failed) {
+				if (count < workers || now) {
+				    if (logger.isInfoEnabled()) {
+				        logger.info("Adding short shutdown watchdog: count = " + 
+				            count + ", workers = " + workers + ", now = " + now);
+				    }
+                    addForcedShutdownWatchdog(100);
+	            }
+				else {
+				    if (logger.isInfoEnabled()) {
+				        logger.info("Adding normal shutdown watchdog");
+				    }
+   					addForcedShutdownWatchdog(SHUTDOWN_WATCHDOG_DELAY);
 				}
+			}
 
-                if (idleTotal > 0) {
-                    double u = (busyTotal * 10000) / (busyTotal + idleTotal);
-                    u /= 100;
-                    logger.info("Average utilization: " + u + "%");
-                    bqp.getRLogger().log("BLOCK_UTILIZATION id=" + getId() + ", u=" + u);
-                }
+            if (idleTotal > 0) {
+                double u = (busyTotal * 10000) / (busyTotal + idleTotal);
+                u /= 100;
+                logger.info("Average utilization: " + u + "%");
+                bqp.getRLogger().log("BLOCK_UTILIZATION id=" + getId() + ", u=" + u);
             }
-            else {
-                logger.info("Block " + this + " not running. Cancelling job.");
-                forceShutdown();
-            }
-            cpus.clear();
         }
+        else {
+            logger.info("Block " + this + " not running. Cancelling job.");
+            forceShutdown();
+        }
     }
 
     private void addForcedShutdownWatchdog(long delay) {



More information about the Swift-commit mailing list