Skip to content

Commit be41032

Browse files
author
Stephane Maldini
committed
try detecting outbound-complete with autoRead only if non keep alive
leave onOutboundComplete takes precedence for terminal event clear channelOperation before writing response
1 parent 6235734 commit be41032

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/main/java/reactor/ipc/netty/http/server/HttpServerOperations.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011-2018 Pivotal Software Inc, All Rights Reserved.
2+
* Copyright (c) 2011-2017 Pivotal Software Inc, All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -367,13 +367,9 @@ protected void onInboundNext(ChannelHandlerContext ctx, Object msg) {
367367
}
368368
if (msg instanceof LastHttpContent) {
369369
onInboundComplete();
370-
if (isOutboundDone()) {
371-
onHandlerTerminate();
372-
}
373-
else {
374-
//force auto read to enable more accurate close selection now inbound is done
370+
if (!isKeepAlive()) {
375371
channel().config()
376-
.setAutoRead(true);
372+
.setAutoRead(true); //detect close
377373
}
378374
}
379375
}
@@ -388,6 +384,8 @@ protected void onOutboundComplete() {
388384
return;
389385
}
390386

387+
onHandlerTerminate();
388+
391389
final ChannelFuture f;
392390
if (log.isDebugEnabled()) {
393391
log.debug("Last HTTP response frame");
@@ -404,16 +402,15 @@ else if (markSentBody()) {
404402
}
405403
else{
406404
discard();
407-
onHandlerTerminate();
408405
return;
409406
}
410407
f.addListener(s -> {
411408
discard();
412-
onHandlerTerminate();
413409
if (!s.isSuccess() && log.isDebugEnabled()) {
414-
log.error("Failed flushing last frame", s.cause());
410+
log.error(channel()+" Failed flushing last frame", s.cause());
415411
}
416412
});
413+
417414
}
418415

419416
@Override

0 commit comments

Comments
 (0)