Index: httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java =================================================================== --- httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java (revision 1534602) +++ httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java (working copy) @@ -210,6 +210,10 @@ return this.status; } + protected IOReactorConfig getConfig() { + return config; + } + /** * Returns the audit log containing exceptions thrown by the I/O reactor * prior and in the course of the reactor shutdown. Index: httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultListeningIOReactor.java =================================================================== --- httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultListeningIOReactor.java (revision 1534602) +++ httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultListeningIOReactor.java (working copy) @@ -234,7 +234,7 @@ final ServerSocket socket = serverChannel.socket(); socket.setReuseAddress(this.config.isSoReuseAddress()); serverChannel.configureBlocking(false); - socket.bind(address); + socket.bind(address, getConfig().getBacklogSize()); } catch (final IOException ex) { closeChannel(serverChannel); request.failed(ex); Index: httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOReactorConfig.java =================================================================== --- httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOReactorConfig.java (revision 1534602) +++ httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOReactorConfig.java (working copy) @@ -55,6 +55,7 @@ private int connectTimeout; private int sndBufSize; private int rcvBufSize; + private int backlogSize; @Deprecated public IOReactorConfig() { @@ -71,6 +72,7 @@ this.connectTimeout = 0; this.sndBufSize = 0; this.rcvBufSize = 0; + this.backlogSize = 0; } IOReactorConfig( @@ -85,7 +87,8 @@ final boolean tcpNoDelay, final int connectTimeout, final int sndBufSize, - final int rcvBufSize) { + final int rcvBufSize, + final int backlogSize) { super(); this.selectInterval = selectInterval; this.shutdownGracePeriod = shutdownGracePeriod; @@ -99,6 +102,7 @@ this.connectTimeout = connectTimeout; this.sndBufSize = sndBufSize; this.rcvBufSize = rcvBufSize; + this.backlogSize = backlogSize; } /** @@ -336,6 +340,15 @@ this.rcvBufSize = rcvBufSize; } + /** + * Determines the default backlog size value for server sockets binds. + *
+ * Default:0 (system default)
+ */
+ public int getBacklogSize() {
+ return backlogSize;
+ }
+
@Override
protected IOReactorConfig clone() throws CloneNotSupportedException {
return (IOReactorConfig) super.clone();
@@ -357,7 +370,10 @@
.setSoLinger(config.getSoLinger())
.setSoKeepAlive(config.isSoKeepalive())
.setTcpNoDelay(config.isTcpNoDelay())
- .setConnectTimeout(config.getConnectTimeout());
+ .setConnectTimeout(config.getConnectTimeout())
+ .setSndBufSize(config.getSndBufSize())
+ .setRcvBufSize(config.getRcvBufSize())
+ .setBacklogSize(config.getBacklogSize());
}
public static class Builder {
@@ -374,6 +390,7 @@
private int connectTimeout;
private int sndBufSize;
private int rcvBufSize;
+ private int backlogSize;
Builder() {
this.selectInterval = 1000;
@@ -388,6 +405,7 @@
this.connectTimeout = 0;
this.sndBufSize = 0;
this.rcvBufSize = 0;
+ this.backlogSize = 0;
}
public Builder setSelectInterval(final long selectInterval) {
@@ -450,11 +468,16 @@
return this;
}
+ public Builder setBacklogSize(final int backlogSize) {
+ this.backlogSize = backlogSize;
+ return this;
+ }
+
public IOReactorConfig build() {
return new IOReactorConfig(
selectInterval, shutdownGracePeriod, interestOpQueued, ioThreadCount,
soTimeout, soReuseAddress, soLinger, soKeepAlive, tcpNoDelay,
- connectTimeout, sndBufSize, rcvBufSize);
+ connectTimeout, sndBufSize, rcvBufSize, backlogSize);
}
}
@@ -474,6 +497,7 @@
.append(", connectTimeout=").append(this.connectTimeout)
.append(", sndBufSize=").append(this.sndBufSize)
.append(", rcvBufSize=").append(this.rcvBufSize)
+ .append(", backlogSize=").append(this.backlogSize)
.append("]");
return builder.toString();
}