From f3d4b4f846a7f72929b70c23a0223be52b8daf07 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Fri, 18 Feb 2022 23:08:47 +0900 Subject: [PATCH] nghttpx: Fix bug that h3 stream ends prematurely --- src/shrpx_http3_upstream.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/shrpx_http3_upstream.cc b/src/shrpx_http3_upstream.cc index 6c43f273..d2036a53 100644 --- a/src/shrpx_http3_upstream.cc +++ b/src/shrpx_http3_upstream.cc @@ -1202,9 +1202,8 @@ nghttp3_ssize downstream_read_data_callback(nghttp3_conn *conn, assert(body); - if (downstream->get_response_state() == DownstreamState::MSG_COMPLETE) { - *pflags |= NGHTTP3_DATA_FLAG_EOF; - } else if (body->rleft_mark() == 0) { + if (downstream->get_response_state() != DownstreamState::MSG_COMPLETE && + body->rleft_mark() == 0) { downstream->disable_upstream_wtimer(); return NGHTTP3_ERR_WOULDBLOCK; } @@ -1213,6 +1212,11 @@ nghttp3_ssize downstream_read_data_callback(nghttp3_conn *conn, veccnt = body->riovec_mark(reinterpret_cast(vec), veccnt); + if (downstream->get_response_state() == DownstreamState::MSG_COMPLETE && + body->rleft_mark() == 0) { + *pflags |= NGHTTP3_DATA_FLAG_EOF; + } + assert((*pflags & NGHTTP3_DATA_FLAG_EOF) || veccnt); downstream->response_sent_body_length += nghttp3_vec_len(vec, veccnt);