zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cami...@apache.org
Subject zookeeper git commit: ZOOKEEPER-2836: fix SocketTimeoutException
Date Wed, 23 Aug 2017 00:16:33 GMT
Repository: zookeeper
Updated Branches:
  refs/heads/master b64d50441 -> 52aff3eca


ZOOKEEPER-2836: fix SocketTimeoutException

Author: bitgaoshu <bitgaoshu@gmail.com>

Reviewers: camille camille@apache.org

Closes #336 from bitgaoshu/ZOOKEEPER-2836


Project: http://git-wip-us.apache.org/repos/asf/zookeeper/repo
Commit: http://git-wip-us.apache.org/repos/asf/zookeeper/commit/52aff3ec
Tree: http://git-wip-us.apache.org/repos/asf/zookeeper/tree/52aff3ec
Diff: http://git-wip-us.apache.org/repos/asf/zookeeper/diff/52aff3ec

Branch: refs/heads/master
Commit: 52aff3eca439bba70f2b4d175ce331754dcd03db
Parents: b64d504
Author: bitgaoshu <bitgaoshu@gmail.com>
Authored: Tue Aug 22 20:16:27 2017 -0400
Committer: Camille Fournier <camille@apache.org>
Committed: Tue Aug 22 20:16:27 2017 -0400

----------------------------------------------------------------------
 .../server/quorum/QuorumCnxManager.java          | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zookeeper/blob/52aff3ec/src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java b/src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java
index eab1338..c8f73a3 100644
--- a/src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java
+++ b/src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java
@@ -26,6 +26,7 @@ import java.net.InetSocketAddress;
 import java.net.ServerSocket;
 import java.net.Socket;
 import java.net.SocketException;
+import java.net.SocketTimeoutException;
 import java.nio.BufferUnderflowException;
 import java.nio.ByteBuffer;
 import java.nio.channels.UnresolvedAddressException;
@@ -639,12 +640,18 @@ public class QuorumCnxManager {
                     setName(addr.toString());
                     ss.bind(addr);
                     while (!shutdown) {
-                        client = ss.accept();
-                        setSockOpts(client);
-                        LOG.info("Received connection request "
-                                + client.getRemoteSocketAddress());
-                        receiveConnection(client);
-                        numRetries = 0;
+                        try {
+                            client = ss.accept();
+                            setSockOpts(client);
+                            LOG.info("Received connection request "
+                                     + client.getRemoteSocketAddress());
+                            receiveConnection(client);
+                            numRetries = 0;
+                        } catch (SocketTimeoutException e) {
+                            LOG.warn("The socket is listening for the election accepted "
+                                     + "and it timed out unexpectedly, but will retry."
+                                     + "see ZOOKEEPER-2836");
+                        }
                     }
                 } catch (IOException e) {
                     if (shutdown) {


Mime
View raw message