You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by ju...@apache.org on 2016/03/21 03:58:38 UTC

kafka git commit: KAFKA-3378; Follow-up to ensure we `finishConnect` for immediately connected keys

Repository: kafka
Updated Branches:
  refs/heads/trunk c188a68e2 -> 95eabc8c8


KAFKA-3378; Follow-up to ensure we `finishConnect` for immediately connected keys

Author: Ismael Juma <is...@juma.me.uk>

Reviewers: Larkin Lowrey <ll...@gmail.com>, Jun Rao <ju...@gmail.com>

Closes #1103 from ijuma/kafka-3378-follow-up


Project: http://git-wip-us.apache.org/repos/asf/kafka/repo
Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/95eabc8c
Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/95eabc8c
Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/95eabc8c

Branch: refs/heads/trunk
Commit: 95eabc8c8b383af84466d4c2cfafd0920e5a52ee
Parents: c188a68
Author: Ismael Juma <is...@juma.me.uk>
Authored: Sun Mar 20 19:58:31 2016 -0700
Committer: Jun Rao <ju...@gmail.com>
Committed: Sun Mar 20 19:58:31 2016 -0700

----------------------------------------------------------------------
 .../java/org/apache/kafka/common/network/Selector.java    | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/95eabc8c/clients/src/main/java/org/apache/kafka/common/network/Selector.java
----------------------------------------------------------------------
diff --git a/clients/src/main/java/org/apache/kafka/common/network/Selector.java b/clients/src/main/java/org/apache/kafka/common/network/Selector.java
index f9e232d..698b99c 100644
--- a/clients/src/main/java/org/apache/kafka/common/network/Selector.java
+++ b/clients/src/main/java/org/apache/kafka/common/network/Selector.java
@@ -280,8 +280,8 @@ public class Selector implements Selectable {
         this.sensors.selectTime.record(endSelect - startSelect, time.milliseconds());
 
         if (readyKeys > 0 || !immediatelyConnectedKeys.isEmpty()) {
-            pollSelectionKeys(this.nioSelector.selectedKeys());
-            pollSelectionKeys(immediatelyConnectedKeys);
+            pollSelectionKeys(this.nioSelector.selectedKeys(), false);
+            pollSelectionKeys(immediatelyConnectedKeys, true);
         }
 
         addToCompletedReceives();
@@ -291,7 +291,7 @@ public class Selector implements Selectable {
         maybeCloseOldestConnection();
     }
 
-    private void pollSelectionKeys(Iterable<SelectionKey> selectionKeys) {
+    private void pollSelectionKeys(Iterable<SelectionKey> selectionKeys, boolean isImmediatelyConnected) {
         Iterator<SelectionKey> iterator = selectionKeys.iterator();
         while (iterator.hasNext()) {
             SelectionKey key = iterator.next();
@@ -304,8 +304,8 @@ public class Selector implements Selectable {
 
             try {
 
-                /* complete any connections that have finished their handshake */
-                if (key.isConnectable()) {
+                /* complete any connections that have finished their handshake (either normally or immediately) */
+                if (isImmediatelyConnected || key.isConnectable()) {
                     if (channel.finishConnect()) {
                         this.connected.add(channel.id());
                         this.sensors.connectionCreated.record();