From e55abcd634893ecbb9742e7b8913324a9b071fd2 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 24 Aug 2013 00:28:50 +0900 Subject: [PATCH] nghttpx: Fix stream hang when http2 downstream CONNECT failed --- src/shrpx_spdy_downstream_connection.cc | 6 +++++- src/shrpx_spdy_session.cc | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/shrpx_spdy_downstream_connection.cc b/src/shrpx_spdy_downstream_connection.cc index e0a3ba90..83c589b4 100644 --- a/src/shrpx_spdy_downstream_connection.cc +++ b/src/shrpx_spdy_downstream_connection.cc @@ -180,8 +180,12 @@ ssize_t spdy_data_read_callback(nghttp2_session *session, nread = evbuffer_remove(body, buf, length); if(nread == 0) { if(downstream->get_request_state() == Downstream::MSG_COMPLETE) { - if(!downstream->get_upgrade_request()) { + if(!downstream->get_upgrade_request() || + (downstream->get_response_state() == Downstream::HEADER_COMPLETE && + !downstream->get_upgraded())) { *eof = 1; + } else { + return NGHTTP2_ERR_DEFERRED; } break; } else { diff --git a/src/shrpx_spdy_session.cc b/src/shrpx_spdy_session.cc index 453db1e1..e57a623b 100644 --- a/src/shrpx_spdy_session.cc +++ b/src/shrpx_spdy_session.cc @@ -828,6 +828,10 @@ void on_frame_recv_callback SSLOG(INFO, spdy) << "HTTP upgrade success. stream_id=" << frame->hd.stream_id; } + } else if(downstream->get_request_method() == "CONNECT") { + // If request is CONNECT, terminate request body to avoid for + // stream to stall. + downstream->end_upload_data(); } rv = upstream->on_downstream_header_complete(downstream); if(rv != 0) {