Merge remote-tracking branch 'origin/jetty-9.3.x' into jetty-9.4.x
This commit is contained in:
commit
9da52222fd
|
@ -279,36 +279,44 @@ public class ServerConnector extends AbstractNetworkConnector
|
|||
{
|
||||
if (_acceptChannel == null)
|
||||
{
|
||||
ServerSocketChannel serverChannel = null;
|
||||
if (isInheritChannel())
|
||||
{
|
||||
Channel channel = System.inheritedChannel();
|
||||
if (channel instanceof ServerSocketChannel)
|
||||
serverChannel = (ServerSocketChannel)channel;
|
||||
else
|
||||
LOG.warn("Unable to use System.inheritedChannel() [{}]. Trying a new ServerSocketChannel at {}:{}", channel, getHost(), getPort());
|
||||
}
|
||||
|
||||
if (serverChannel == null)
|
||||
{
|
||||
serverChannel = ServerSocketChannel.open();
|
||||
|
||||
InetSocketAddress bindAddress = getHost() == null ? new InetSocketAddress(getPort()) : new InetSocketAddress(getHost(), getPort());
|
||||
serverChannel.socket().setReuseAddress(getReuseAddress());
|
||||
serverChannel.socket().bind(bindAddress, getAcceptQueueSize());
|
||||
|
||||
_localPort = serverChannel.socket().getLocalPort();
|
||||
if (_localPort <= 0)
|
||||
throw new IOException("Server channel not bound");
|
||||
}
|
||||
|
||||
serverChannel.configureBlocking(true);
|
||||
addBean(serverChannel);
|
||||
|
||||
_acceptChannel = serverChannel;
|
||||
_acceptChannel = openAcceptChannel();
|
||||
_acceptChannel.configureBlocking(true);
|
||||
_localPort = _acceptChannel.socket().getLocalPort();
|
||||
if (_localPort <= 0)
|
||||
throw new IOException("Server channel not bound");
|
||||
addBean(_acceptChannel);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by {@link #open()} to obtain the accepting channel.
|
||||
* @return ServerSocketChannel used to accept connections.
|
||||
* @throws IOException
|
||||
*/
|
||||
protected ServerSocketChannel openAcceptChannel() throws IOException
|
||||
{
|
||||
ServerSocketChannel serverChannel = null;
|
||||
if (isInheritChannel())
|
||||
{
|
||||
Channel channel = System.inheritedChannel();
|
||||
if (channel instanceof ServerSocketChannel)
|
||||
serverChannel = (ServerSocketChannel)channel;
|
||||
else
|
||||
LOG.warn("Unable to use System.inheritedChannel() [{}]. Trying a new ServerSocketChannel at {}:{}", channel, getHost(), getPort());
|
||||
}
|
||||
|
||||
if (serverChannel == null)
|
||||
{
|
||||
serverChannel = ServerSocketChannel.open();
|
||||
|
||||
InetSocketAddress bindAddress = getHost() == null ? new InetSocketAddress(getPort()) : new InetSocketAddress(getHost(), getPort());
|
||||
serverChannel.socket().setReuseAddress(getReuseAddress());
|
||||
serverChannel.socket().bind(bindAddress, getAcceptQueueSize());
|
||||
}
|
||||
|
||||
return serverChannel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Future<Void> shutdown()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue