فهرست منبع

Merging HDFS-1118 change r956329 from 0.20-append to 0.20-security

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.20-security@1160447 13f79535-47bb-0310-9956-ffa450edef68
Suresh Srinivas 14 سال پیش
والد
کامیت
7e490943ea
2فایلهای تغییر یافته به همراه12 افزوده شده و 2 حذف شده
  1. 3 0
      CHANGES.txt
  2. 9 2
      src/hdfs/org/apache/hadoop/hdfs/DFSClient.java

+ 3 - 0
CHANGES.txt

@@ -45,6 +45,9 @@ Release 0.20.205.0 - unreleased
     HDFS-606. Fix ConcurrentModificationException in invalidateCorruptReplicas.
     (Todd Lipcon via dhruba)
 
+    HDFS-1118. Fix socketleak on DFSClient. 
+    (Zheng Shao via dhruba)
+
   IMPROVEMENTS
 
     MAPREDUCE-2187. Reporter sends progress during sort/merge. (Anupam Seth via

+ 9 - 2
src/hdfs/org/apache/hadoop/hdfs/DFSClient.java

@@ -3033,6 +3033,7 @@ public class DFSClient implements FSConstants, java.io.Closeable {
       // persist blocks on namenode on next flush
       persistBlocks = true;
 
+      boolean result = false;
       try {
         LOG.debug("Connecting to " + nodes[0].getName());
         InetSocketAddress target = NetUtils.createSocketAddr(nodes[0].getName());
@@ -3084,7 +3085,7 @@ public class DFSClient implements FSConstants, java.io.Closeable {
         }
 
         blockStream = out;
-        return true;     // success
+        result = true;     // success
 
       } catch (IOException ie) {
 
@@ -3102,8 +3103,14 @@ public class DFSClient implements FSConstants, java.io.Closeable {
         hasError = true;
         setLastException(ie);
         blockReplyStream = null;
-        return false;  // error
+        result = false;
+      } finally {
+        if (!result) {
+          IOUtils.closeSocket(s);
+          s = null;
+        }
       }
+      return result;
     }
   
     private LocatedBlock locateFollowingBlock(long start