Skip to content

Commit

Permalink
try detecting outbound-complete with autoRead only if non keep alive
Browse files Browse the repository at this point in the history
leave onOutboundComplete takes precedence for terminal event
clear channelOperation before writing response
  • Loading branch information
Stephane Maldini committed Jan 19, 2018
1 parent 6235734 commit be41032
Showing 1 changed file with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2018 Pivotal Software Inc, All Rights Reserved.
* Copyright (c) 2011-2017 Pivotal Software Inc, All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -367,13 +367,9 @@ protected void onInboundNext(ChannelHandlerContext ctx, Object msg) {
}
if (msg instanceof LastHttpContent) {
onInboundComplete();
if (isOutboundDone()) {
onHandlerTerminate();
}
else {
//force auto read to enable more accurate close selection now inbound is done
if (!isKeepAlive()) {
channel().config()
.setAutoRead(true);
.setAutoRead(true); //detect close
}
}
}
Expand All @@ -388,6 +384,8 @@ protected void onOutboundComplete() {
return;
}

onHandlerTerminate();

final ChannelFuture f;
if (log.isDebugEnabled()) {
log.debug("Last HTTP response frame");
Expand All @@ -404,16 +402,15 @@ else if (markSentBody()) {
}
else{
discard();
onHandlerTerminate();
return;
}
f.addListener(s -> {
discard();
onHandlerTerminate();
if (!s.isSuccess() && log.isDebugEnabled()) {
log.error("Failed flushing last frame", s.cause());
log.error(channel()+" Failed flushing last frame", s.cause());
}
});

}

@Override
Expand Down

0 comments on commit be41032

Please sign in to comment.