Merge pull request #490 from jfallows/master
Eliminate potential ReadPendingException for AIO suspend-resume
This commit is contained in:
commit
b09e945830
@ -54,6 +54,7 @@ public class AioSocketChannel extends AbstractAioChannel implements SocketChanne
|
|||||||
private boolean flushing;
|
private boolean flushing;
|
||||||
|
|
||||||
private final AtomicBoolean readSuspended = new AtomicBoolean();
|
private final AtomicBoolean readSuspended = new AtomicBoolean();
|
||||||
|
private final AtomicBoolean readInProgress = new AtomicBoolean();
|
||||||
|
|
||||||
private final Runnable readTask = new Runnable() {
|
private final Runnable readTask = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -191,6 +192,11 @@ public class AioSocketChannel extends AbstractAioChannel implements SocketChanne
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// prevent ReadPendingException
|
||||||
|
if (!readInProgress.compareAndSet(false, true)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ByteBuf byteBuf = pipeline().inboundByteBuffer();
|
ByteBuf byteBuf = pipeline().inboundByteBuffer();
|
||||||
if (!byteBuf.readable()) {
|
if (!byteBuf.readable()) {
|
||||||
byteBuf.discardReadBytes();
|
byteBuf.discardReadBytes();
|
||||||
@ -297,6 +303,9 @@ public class AioSocketChannel extends AbstractAioChannel implements SocketChanne
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
// see beginRead
|
||||||
|
channel.readInProgress.set(false);
|
||||||
|
|
||||||
if (read) {
|
if (read) {
|
||||||
if (!channel.readSuspended.get()) {
|
if (!channel.readSuspended.get()) {
|
||||||
pipeline.fireInboundBufferUpdated();
|
pipeline.fireInboundBufferUpdated();
|
||||||
|
Loading…
Reference in New Issue
Block a user