[#1388] Ensure AbstractNioMessageChannel based Channels will call fireInboundBufferUpdated() soon enough to release resources
This commit is contained in:
parent
83dcf829d6
commit
50ac0cdfcb
@ -28,6 +28,9 @@ import java.nio.channels.SelectionKey;
|
||||
*/
|
||||
public abstract class AbstractNioMessageChannel extends AbstractNioChannel {
|
||||
|
||||
// Hard coded for now.
|
||||
private static final int READ_BATCH_SIZE = 16;
|
||||
|
||||
/**
|
||||
* @see {@link AbstractNioChannel#AbstractNioChannel(Channel, Integer, SelectableChannel, int)}
|
||||
*/
|
||||
@ -56,15 +59,21 @@ public abstract class AbstractNioMessageChannel extends AbstractNioChannel {
|
||||
boolean closed = false;
|
||||
boolean read = false;
|
||||
boolean firedChannelReadSuspended = false;
|
||||
loop: for (;;) {
|
||||
int reads = 0;
|
||||
|
||||
try {
|
||||
for (;;) {
|
||||
int localReadAmount = doReadMessages(msgBuf);
|
||||
if (localReadAmount > 0) {
|
||||
read = true;
|
||||
} else if (localReadAmount == 0) {
|
||||
break;
|
||||
break loop;
|
||||
} else if (localReadAmount < 0) {
|
||||
closed = true;
|
||||
break loop;
|
||||
}
|
||||
if (reads++ > READ_BATCH_SIZE) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -94,6 +103,7 @@ public abstract class AbstractNioMessageChannel extends AbstractNioChannel {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doFlushMessageBuffer(MessageBuf<Object> buf) throws Exception {
|
||||
|
Loading…
Reference in New Issue
Block a user