瀏覽代碼

HDFS-11387. Socket reuse address option is not honored in PrivilegedNfsGatewayStarter. Contributed by Mukul Kumar Singh.

Arpit Agarwal 8 年之前
父節點
當前提交
f17d3eddcf

+ 4 - 2
hadoop-hdfs-project/hadoop-hdfs-nfs/src/main/java/org/apache/hadoop/hdfs/nfs/nfs3/PrivilegedNfsGatewayStarter.java

@@ -54,9 +54,11 @@ public class PrivilegedNfsGatewayStarter implements Daemon {
     }
 
     try {
-      registrationSocket = new DatagramSocket(
-                    new InetSocketAddress("localhost", clientPort));
+      InetSocketAddress socketAddress =
+                new InetSocketAddress("localhost", clientPort);
+      registrationSocket = new DatagramSocket(null);
       registrationSocket.setReuseAddress(true);
+      registrationSocket.bind(socketAddress);
     } catch (SocketException e) {
       LOG.error("Init failed for port=" + clientPort, e);
       throw e;