[Swift-commit] cog r3483

swift at ci.uchicago.edu swift at ci.uchicago.edu
Fri Oct 5 16:30:14 CDT 2012


------------------------------------------------------------------------
r3483 | hategan | 2012-10-05 16:25:28 -0500 (Fri, 05 Oct 2012) | 1 line

fixed potential deadlock (swift bug 841)
------------------------------------------------------------------------
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 3482)
+++ modules/provider-coaster/src/org/globus/cog/abstraction/coaster/service/job/manager/Block.java	(working copy)
@@ -81,7 +81,7 @@
         this.walltime = walltime;
         this.bqp = ap;
         this.creationtime = Time.now();
-        this.deadline = Time.now().add(ap.getSettings().getReserve());
+        setDeadline(Time.now().add(ap.getSettings().getReserve()));
         requestedWorkers += workers;
     }
 
@@ -130,9 +130,9 @@
                     last = Time.now();
                 }
             }
-            deadline =
-                    Time.min(starttime.add(walltime),
+            Time deadline = Time.min(starttime.add(walltime),
                         last.add(bqp.getSettings().getMaxWorkerIdleTime()));
+            setDeadline(deadline);
             return Time.now().isGreaterThan(deadline);
         }
         else {
@@ -184,17 +184,17 @@
     }
 
     public void add(Cpu cpu) {
+    	Cpu last = null;
         synchronized (cpus) {
             if (!scpus.add(cpu)) {
                 CoasterService.error(15, "CPU is already in the block", new Throwable());
             }
-            Cpu last = scpus.last();
-            if (last != null) {
-                deadline =
-                        Time.min(last.getTimeLast().add(bqp.getSettings().getReserve()),
-                            getEndTime());
-            }
+            last = scpus.last();
         }
+        if (last != null) {
+            setDeadline(Time.min(last.getTimeLast().add(bqp.getSettings().getReserve()),
+                getEndTime()));
+        }
     }
 
     public void shutdownIfEmpty(Cpu cpu) {
@@ -445,7 +445,7 @@
             else if (s.getStatusCode() == Status.ACTIVE) {
                 starttime = Time.now();
                 endtime = starttime.add(walltime);
-                deadline = starttime.add(bqp.getSettings().getReserve());
+                setDeadline(starttime.add(bqp.getSettings().getReserve()));
                 running = true;
                 bqp.getRLogger().log("BLOCK_ACTIVE id=" + getId());
                 bqp.getSettings().getHook().blockActive(event);
@@ -477,11 +477,11 @@
         return deadline;
     }
 
-    public void setDeadline(Time t) {
+    public synchronized void setDeadline(Time t) {
         this.deadline = t;
     }
 
-    public Time getCreationTime() {
+    public synchronized Time getCreationTime() {
         return creationtime;
     }
 



More information about the Swift-commit mailing list