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


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

Author: Ismael Juma <[email protected]>

Reviewers: Larkin Lowrey <[email protected]>, Jun Rao <[email protected]>

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 <[email protected]>
Authored: Sun Mar 20 19:58:31 2016 -0700
Committer: Jun Rao <[email protected]>
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();

Reply via email to