Procházet zdrojové kódy

merge -r581426:581427 from trunk to 0.14. Fixed HADOOP-1970.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/branches/branch-0.14@581428 13f79535-47bb-0310-9956-ffa450edef68
Owen O'Malley před 17 roky
rodič
revize
c72aa0b7d4
2 změnil soubory, kde provedl 16 přidání a 4 odebrání
  1. 3 0
      CHANGES.txt
  2. 13 4
      src/java/org/apache/hadoop/util/Progress.java

+ 3 - 0
CHANGES.txt

@@ -17,6 +17,9 @@ Release 0.14.2 (unreleased changes)
     HADOOP-1972.  Fix LzoCompressor to ensure the user has actually asked
     to finish compression. (arun via omalley)
 
+    HADOOP-1970.  Fix deadlock in progress reporting in the task. (Vivek
+    Ratan via omalley)
+
 Release 0.14.1 - 2007-09-04
 
   BUG FIXES

+ 13 - 4
src/java/org/apache/hadoop/util/Progress.java

@@ -64,10 +64,19 @@ public class Progress {
   }
 
   /** Completes this node, moving the parent node to its next child. */
-  public synchronized void complete() {
-    progress = 1.0f;
-    if (parent != null) {
-      parent.startNextPhase();
+  public void complete() {
+    // we have to traverse up to our parent, so be careful about locking.
+    Progress myParent;
+    synchronized(this) {
+      progress = 1.0f;
+      myParent = parent;
+    }
+    if (myParent != null) {
+      // this will synchronize on the parent, so we make sure we release
+      // our lock before getting the parent's, since we're traversing 
+      // against the normal traversal direction used by get() or toString().
+      // We don't need transactional semantics, so we're OK doing this. 
+      myParent.startNextPhase();
     }
   }