zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ph...@apache.org
Subject svn commit: r1234976 - in /zookeeper/branches/branch-3.3: CHANGES.txt src/java/main/org/apache/zookeeper/server/quorum/Leader.java
Date Mon, 23 Jan 2012 20:34:31 GMT
Author: phunt
Date: Mon Jan 23 20:34:31 2012
New Revision: 1234976

URL: http://svn.apache.org/viewvc?rev=1234976&view=rev
Log:
ZOOKEEPER-973. bind() could fail on Leader because it does not setReuseAddress on its ServerSocket
(Harsh J via phunt)

Modified:
    zookeeper/branches/branch-3.3/CHANGES.txt
    zookeeper/branches/branch-3.3/src/java/main/org/apache/zookeeper/server/quorum/Leader.java

Modified: zookeeper/branches/branch-3.3/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.3/CHANGES.txt?rev=1234976&r1=1234975&r2=1234976&view=diff
==============================================================================
--- zookeeper/branches/branch-3.3/CHANGES.txt (original)
+++ zookeeper/branches/branch-3.3/CHANGES.txt Mon Jan 23 20:34:31 2012
@@ -9,6 +9,8 @@ BUGFIXES:
   ZOOKEEPER-1345. Add a .gitignore file with general exclusions and
   Eclipse project files excluded (Harsh J via phunt)
  
+  ZOOKEEPER-973. bind() could fail on Leader because it does not
+  setReuseAddress on its ServerSocket (Harsh J via phunt)
 
 Release 3.3.4 - 2011-11-16
 Backward compatible changes:

Modified: zookeeper/branches/branch-3.3/src/java/main/org/apache/zookeeper/server/quorum/Leader.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.3/src/java/main/org/apache/zookeeper/server/quorum/Leader.java?rev=1234976&r1=1234975&r2=1234976&view=diff
==============================================================================
--- zookeeper/branches/branch-3.3/src/java/main/org/apache/zookeeper/server/quorum/Leader.java
(original)
+++ zookeeper/branches/branch-3.3/src/java/main/org/apache/zookeeper/server/quorum/Leader.java
Mon Jan 23 20:34:31 2012
@@ -21,6 +21,7 @@ package org.apache.zookeeper.server.quor
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.net.BindException;
+import java.net.InetSocketAddress;
 import java.net.ServerSocket;
 import java.net.Socket;
 import java.net.SocketAddress;
@@ -128,7 +129,9 @@ public class Leader {
     Leader(QuorumPeer self,LeaderZooKeeperServer zk) throws IOException {
         this.self = self;
         try {
-            ss = new ServerSocket(self.getQuorumAddress().getPort());
+            ss = new ServerSocket();
+            ss.setReuseAddress(true);
+            ss.bind(new InetSocketAddress(self.getQuorumAddress().getPort()));
         } catch (BindException e) {
             LOG.error("Couldn't bind to port "
                     + self.getQuorumAddress().getPort(), e);



Mime
View raw message