hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject [19/34] httpcomponents-core git commit: Apply initial socket parameters prior to bind operation
Date Tue, 09 May 2017 20:02:48 GMT
Apply initial socket parameters prior to bind operation

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.3.x@1596943
13f79535-47bb-0310-9956-ffa450edef68


Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/674135b2
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/674135b2
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/674135b2

Branch: refs/heads/4.3.x
Commit: 674135b2472c033766243fd7da59661855ca9484
Parents: f4efa0c
Author: Oleg Kalnichevski <olegk@apache.org>
Authored: Thu May 22 19:13:12 2014 +0000
Committer: Oleg Kalnichevski <olegk@apache.org>
Committed: Thu May 22 19:13:12 2014 +0000

----------------------------------------------------------------------
 .../http/impl/nio/reactor/DefaultConnectingIOReactor.java       | 5 +++--
 .../main/java/org/apache/http/impl/pool/BasicConnFactory.java   | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/674135b2/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java
b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java
index 77dbeed..cdf7035 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java
@@ -259,16 +259,17 @@ public class DefaultConnectingIOReactor extends AbstractMultiworkerIOReactor
                 throw new IOReactorException("Failure opening socket", ex);
             }
             try {
-                socketChannel.configureBlocking(false);
                 validateAddress(request.getLocalAddress());
                 validateAddress(request.getRemoteAddress());
 
+                socketChannel.configureBlocking(false);
+                prepareSocket(socketChannel.socket());
+
                 if (request.getLocalAddress() != null) {
                     final Socket sock = socketChannel.socket();
                     sock.setReuseAddress(this.config.isSoReuseAddress());
                     sock.bind(request.getLocalAddress());
                 }
-                prepareSocket(socketChannel.socket());
                 final boolean connected = socketChannel.connect(request.getRemoteAddress());
                 if (connected) {
                     final ChannelEntry entry = new ChannelEntry(socketChannel, request);

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/674135b2/httpcore/src/main/java/org/apache/http/impl/pool/BasicConnFactory.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/pool/BasicConnFactory.java b/httpcore/src/main/java/org/apache/http/impl/pool/BasicConnFactory.java
index 07fb767..0ca55ca 100644
--- a/httpcore/src/main/java/org/apache/http/impl/pool/BasicConnFactory.java
+++ b/httpcore/src/main/java/org/apache/http/impl/pool/BasicConnFactory.java
@@ -164,13 +164,13 @@ public class BasicConnFactory implements ConnFactory<HttpHost, HttpClientConnect
             }
         }
         socket.setSoTimeout(this.sconfig.getSoTimeout());
-        socket.connect(new InetSocketAddress(hostname, port), this.connectTimeout);
         socket.setTcpNoDelay(this.sconfig.isTcpNoDelay());
         final int linger = this.sconfig.getSoLinger();
         if (linger >= 0) {
             socket.setSoLinger(linger > 0, linger);
         }
         socket.setKeepAlive(this.sconfig.isSoKeepAlive());
+        socket.connect(new InetSocketAddress(hostname, port), this.connectTimeout);
         return this.connFactory.createConnection(socket);
     }
 


Mime
View raw message