Merged branch 'master' into 'jetty-9.1'.
This commit is contained in:
commit
03983102e6
|
@ -165,12 +165,12 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Registers a channel to select accept operations.
|
* <p>Registers a server channel for accept operations.
|
||||||
* When a {@link SocketChannel} is accepted from this {@link ServerSocketChannel}
|
* When a {@link SocketChannel} is accepted from the given {@link ServerSocketChannel}
|
||||||
* then the {@link #accepted(SocketChannel)} method is called, which must be
|
* then the {@link #accepted(SocketChannel)} method is called, which must be
|
||||||
* overridden by a derivation of this class to handle the accepted channel
|
* overridden by a derivation of this class to handle the accepted channel
|
||||||
*
|
*
|
||||||
* @param channel the server channel to register
|
* @param server the server channel to register
|
||||||
*/
|
*/
|
||||||
public void acceptor(final ServerSocketChannel server)
|
public void acceptor(final ServerSocketChannel server)
|
||||||
{
|
{
|
||||||
|
@ -180,10 +180,11 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback method when a channel is accepted from the {@link ServerSocketChannel}
|
* Callback method when a channel is accepted from the {@link ServerSocketChannel}
|
||||||
* passed in {@link #acceptor(ServerSocketChannel)}.
|
* passed to {@link #acceptor(ServerSocketChannel)}.
|
||||||
* The default impl throws an {@link UnsupportedOperationException}, so it must
|
* The default impl throws an {@link UnsupportedOperationException}, so it must
|
||||||
* be overridden if selected acceptor is to be used.
|
* be overridden by subclasses if a server channel is provided.
|
||||||
* @param channel
|
*
|
||||||
|
* @param channel the
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
protected void accepted(SocketChannel channel) throws IOException
|
protected void accepted(SocketChannel channel) throws IOException
|
||||||
|
@ -584,13 +585,13 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
||||||
{
|
{
|
||||||
LOG.debug("Ignoring cancelled key for channel {}", key.channel());
|
LOG.debug("Ignoring cancelled key for channel {}", key.channel());
|
||||||
if (attachment instanceof EndPoint)
|
if (attachment instanceof EndPoint)
|
||||||
((EndPoint)attachment).close();
|
closeNoExceptions((EndPoint)attachment);
|
||||||
}
|
}
|
||||||
catch (Throwable x)
|
catch (Throwable x)
|
||||||
{
|
{
|
||||||
LOG.warn("Could not process key for channel " + key.channel(), x);
|
LOG.warn("Could not process key for channel " + key.channel(), x);
|
||||||
if (attachment instanceof EndPoint)
|
if (attachment instanceof EndPoint)
|
||||||
((EndPoint)attachment).close();
|
closeNoExceptions((EndPoint)attachment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -622,17 +623,18 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
||||||
private void processAccept(SelectionKey key)
|
private void processAccept(SelectionKey key)
|
||||||
{
|
{
|
||||||
ServerSocketChannel server = (ServerSocketChannel)key.channel();
|
ServerSocketChannel server = (ServerSocketChannel)key.channel();
|
||||||
|
SocketChannel channel = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
SocketChannel channel;
|
while ((channel = server.accept()) != null)
|
||||||
while ((channel=server.accept())!=null)
|
|
||||||
{
|
{
|
||||||
accepted(channel);
|
accepted(channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Throwable x)
|
catch (Throwable x)
|
||||||
{
|
{
|
||||||
LOG.warn("Accept failed",x);
|
closeNoExceptions(channel);
|
||||||
|
LOG.warn("Accept failed for channel " + channel, x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -640,7 +642,8 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
closeable.close();
|
if (closeable != null)
|
||||||
|
closeable.close();
|
||||||
}
|
}
|
||||||
catch (Throwable x)
|
catch (Throwable x)
|
||||||
{
|
{
|
||||||
|
@ -786,7 +789,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
SelectionKey key = _channel.register(_selector, SelectionKey.OP_ACCEPT, null);
|
SelectionKey key = _channel.register(_selector, SelectionKey.OP_ACCEPT, null);
|
||||||
LOG.debug("{} acceptor={}",this,key);
|
LOG.debug("{} acceptor={}", this, key);
|
||||||
}
|
}
|
||||||
catch (Throwable x)
|
catch (Throwable x)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue