Skip to content

Commit 4764134

Browse files
authored
Clarify writability in Netty4HttpPipeliningHandler (#91982)
TIL we don't really mean that the physical channel is writable in these loops, so this commit adds a couple of comments to record that lesson.
1 parent 788750b commit 4764134

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

modules/transport-netty4/src/main/java/org/elasticsearch/http/netty4/Netty4HttpPipeliningHandler.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@ private void doWrite(ChannelHandlerContext ctx, Netty4ChunkedHttpResponse readyR
216216
combiner.add((Future<Void>) first);
217217
currentChunkedWrite = new ChunkedWrite(combiner, promise, readyResponse);
218218
if (enqueueWrite(ctx, readyResponse, first)) {
219-
// we were able to write out the first chunk directly, try writing out subsequent chunks until the channel becomes unwritable
219+
// We were able to write out the first chunk directly, try writing out subsequent chunks until the channel becomes unwritable.
220+
// NB "writable" means there's space in the downstream ChannelOutboundBuffer, we aren't trying to saturate the physical channel.
220221
while (ctx.channel().isWritable()) {
221222
if (writeChunk(ctx, combiner, readyResponse.body())) {
222223
finishChunkedWrite();
@@ -280,6 +281,7 @@ private boolean doFlush(ChannelHandlerContext ctx) throws IOException {
280281
return false;
281282
}
282283
while (channel.isWritable()) {
284+
// NB "writable" means there's space in the downstream ChannelOutboundBuffer, we aren't trying to saturate the physical channel.
283285
WriteOperation currentWrite = queuedWrites.poll();
284286
if (currentWrite == null) {
285287
doWriteQueued(ctx);

0 commit comments

Comments
 (0)