Fixed a bug where some ChannelPipelineSinks do not always release its shutdownLock on an Error
This commit is contained in:
parent
30d5136973
commit
e8fcbd4e75
@ -234,6 +234,7 @@ class NioServerSocketPipelineSink extends AbstractChannelSink {
|
|||||||
final Thread currentThread = Thread.currentThread();
|
final Thread currentThread = Thread.currentThread();
|
||||||
|
|
||||||
channel.shutdownLock.lock();
|
channel.shutdownLock.lock();
|
||||||
|
try {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
try {
|
try {
|
||||||
if (selector.select(1000) > 0) {
|
if (selector.select(1000) > 0) {
|
||||||
@ -254,7 +255,7 @@ class NioServerSocketPipelineSink extends AbstractChannelSink {
|
|||||||
} catch (ClosedChannelException e) {
|
} catch (ClosedChannelException e) {
|
||||||
// Closed as requested.
|
// Closed as requested.
|
||||||
break;
|
break;
|
||||||
} catch (IOException e) {
|
} catch (Throwable e) {
|
||||||
logger.warn(
|
logger.warn(
|
||||||
"Failed to accept a connection.", e);
|
"Failed to accept a connection.", e);
|
||||||
try {
|
try {
|
||||||
@ -264,10 +265,11 @@ class NioServerSocketPipelineSink extends AbstractChannelSink {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
channel.shutdownLock.unlock();
|
channel.shutdownLock.unlock();
|
||||||
closeSelector();
|
closeSelector();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void registerAcceptedChannel(SocketChannel acceptedSocket, Thread currentThread) {
|
private void registerAcceptedChannel(SocketChannel acceptedSocket, Thread currentThread) {
|
||||||
try {
|
try {
|
||||||
|
@ -201,6 +201,7 @@ class OioServerSocketPipelineSink extends AbstractChannelSink {
|
|||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
channel.shutdownLock.lock();
|
channel.shutdownLock.lock();
|
||||||
|
try {
|
||||||
while (channel.isBound()) {
|
while (channel.isBound()) {
|
||||||
try {
|
try {
|
||||||
Socket acceptedSocket = channel.socket.accept();
|
Socket acceptedSocket = channel.socket.accept();
|
||||||
@ -235,7 +236,7 @@ class OioServerSocketPipelineSink extends AbstractChannelSink {
|
|||||||
}
|
}
|
||||||
} catch (SocketTimeoutException e) {
|
} catch (SocketTimeoutException e) {
|
||||||
// Thrown every second to stop when requested.
|
// Thrown every second to stop when requested.
|
||||||
} catch (IOException e) {
|
} catch (Throwable e) {
|
||||||
// Do not log the exception if the server socket was closed
|
// Do not log the exception if the server socket was closed
|
||||||
// by a user.
|
// by a user.
|
||||||
if (!channel.socket.isBound() || channel.socket.isClosed()) {
|
if (!channel.socket.isBound() || channel.socket.isClosed()) {
|
||||||
@ -251,7 +252,9 @@ class OioServerSocketPipelineSink extends AbstractChannelSink {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
channel.shutdownLock.unlock();
|
channel.shutdownLock.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user