From ecd143fcc2f029e30e5bdb65ac3848647ea93e93 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 22 Nov 2014 23:13:29 +0900 Subject: [PATCH] nghttpx: Send RST_STREAM with NO_ERROR when closing upgraded connection --- src/shrpx_http2_downstream_connection.cc | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/shrpx_http2_downstream_connection.cc b/src/shrpx_http2_downstream_connection.cc index 108b0ccc..f633fc1e 100644 --- a/src/shrpx_http2_downstream_connection.cc +++ b/src/shrpx_http2_downstream_connection.cc @@ -67,7 +67,24 @@ Http2DownstreamConnection::~Http2DownstreamConnection() downstream_->disable_downstream_rtimer(); downstream_->disable_downstream_wtimer(); - if(submit_rst_stream(downstream_) == 0) { + uint32_t error_code; + if(downstream_->get_request_state() == Downstream::STREAM_CLOSED && + downstream_->get_upgraded()) { + // For upgraded connection, send NO_ERROR. Should we consider + // request states other than Downstream::STREAM_CLOSED ? + error_code = NGHTTP2_NO_ERROR; + } else { + error_code = NGHTTP2_INTERNAL_ERROR; + } + + if(LOG_ENABLED(INFO)) { + DCLOG(INFO, this) << "Submit RST_STREAM for DOWNSTREAM:" + << downstream_ << ", stream_id=" + << downstream_->get_downstream_stream_id() + << ", error_code=" << error_code; + } + + if(submit_rst_stream(downstream_, error_code) == 0) { http2session_->notify(); }