Bläddra i källkod

Merge -c 829880 829894 to move the change of HDFS-723 from trunk to branch 0.20.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.20@829987 13f79535-47bb-0310-9956-ffa450edef68
Hairong Kuang 15 år sedan
förälder
incheckning
552bc4f5c6
2 ändrade filer med 13 tillägg och 4 borttagningar
  1. 2 0
      CHANGES.txt
  2. 11 4
      src/hdfs/org/apache/hadoop/hdfs/DFSClient.java

+ 2 - 0
CHANGES.txt

@@ -49,6 +49,8 @@ Release 0.20.2 - Unreleased
     count at the start of each block in Hadoop archives. (Ben Slusky, Tom
     White, and Mahadev Konar via cdouglas)
 
+    HDFS-723. Fix deadlock in DFSClient#DFSOutputStream. (hairong)
+
 Release 0.20.1 - 2009-09-01
 
   INCOMPATIBLE CHANGES

+ 11 - 4
src/hdfs/org/apache/hadoop/hdfs/DFSClient.java

@@ -1023,10 +1023,17 @@ public class DFSClient implements FSConstants, java.io.Closeable {
       }
     }
 
-    synchronized void close() {
-      while (!pendingCreates.isEmpty()) {
-        String src = pendingCreates.firstKey();
-        OutputStream out = pendingCreates.remove(src);
+    void close() {
+      while (true) {
+        String src;
+        OutputStream out;
+        synchronized (this) {
+          if (pendingCreates.isEmpty()) {
+            return;
+          }
+          src = pendingCreates.firstKey();
+          out = pendingCreates.remove(src);
+        }
         if (out != null) {
           try {
             out.close();