hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dhr...@apache.org
Subject svn commit: r956328 - in /hadoop/hdfs/trunk: CHANGES.txt src/java/org/apache/hadoop/hdfs/DFSOutputStream.java
Date Sun, 20 Jun 2010 08:28:25 GMT
Author: dhruba
Date: Sun Jun 20 08:28:25 2010
New Revision: 956328

URL: http://svn.apache.org/viewvc?rev=956328&view=rev
Log:
HDFS-1118. Fix socketleak on DFSClient. 
(Zheng Shao via dhruba)


Modified:
    hadoop/hdfs/trunk/CHANGES.txt
    hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/DFSOutputStream.java

Modified: hadoop/hdfs/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/CHANGES.txt?rev=956328&r1=956327&r2=956328&view=diff
==============================================================================
--- hadoop/hdfs/trunk/CHANGES.txt (original)
+++ hadoop/hdfs/trunk/CHANGES.txt Sun Jun 20 08:28:25 2010
@@ -87,7 +87,9 @@ Trunk (unreleased changes)
     HDFS-1080. SecondaryNameNode image transfer should use the defined http 
     address rather than local ip address. (jghoman)
 
-    HDSF-1198. Resolving cross-realm principals. (Jitendra Pandey via jghoman)
+    HDFS-1198. Resolving cross-realm principals. (Jitendra Pandey via jghoman)
+
+    HDFS-1118. Fix socketleak on DFSClient. (Zheng Shao via dhruba)
 
 Release 0.21.0 - Unreleased
 

Modified: hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/DFSOutputStream.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/DFSOutputStream.java?rev=956328&r1=956327&r2=956328&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/DFSOutputStream.java (original)
+++ hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/DFSOutputStream.java Sun Jun 20 08:28:25
2010
@@ -60,6 +60,7 @@ import org.apache.hadoop.hdfs.server.nam
 import org.apache.hadoop.hdfs.server.namenode.SafeModeException;
 import org.apache.hadoop.io.EnumSetWritable;
 import org.apache.hadoop.io.Text;
+import org.apache.hadoop.io.IOUtils;
 import org.apache.hadoop.ipc.RemoteException;
 import org.apache.hadoop.net.NetUtils;
 import org.apache.hadoop.security.AccessControlException;
@@ -853,6 +854,7 @@ class DFSOutputStream extends FSOutputSu
       // persist blocks on namenode on next flush
       persistBlocks.set(true);
 
+      boolean result = false;
       try {
         DFSClient.LOG.debug("Connecting to " + nodes[0].getName());
         InetSocketAddress target = NetUtils.createSocketAddr(nodes[0].getName());
@@ -895,7 +897,7 @@ class DFSOutputStream extends FSOutputSu
         }
 
         blockStream = out;
-        return true; // success
+        result =  true; // success
 
       } catch (IOException ie) {
 
@@ -915,8 +917,14 @@ class DFSOutputStream extends FSOutputSu
         hasError = true;
         setLastException(ie);
         blockReplyStream = null;
-        return false;  // error
+        result =  false;  // error
+      } finally {
+        if (!result) {
+          IOUtils.closeSocket(s);
+          s = null;
+        }
       }
+      return result;
     }
 
     private LocatedBlock locateFollowingBlock(long start,



Mime
View raw message