From 2795da840c32438f532d9b867938c3b16807a1ab Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sun, 9 Oct 2016 17:18:43 +0900 Subject: [PATCH] nghttpx: Apply timeout for incoming header block --- src/shrpx_http2_upstream.cc | 7 +++++-- src/shrpx_https_upstream.cc | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/shrpx_http2_upstream.cc b/src/shrpx_http2_upstream.cc index 62635007..babd2602 100644 --- a/src/shrpx_http2_upstream.cc +++ b/src/shrpx_http2_upstream.cc @@ -279,6 +279,8 @@ int on_begin_headers_callback(nghttp2_session *session, downstream->reset_upstream_rtimer(); + handler->repeat_read_timer(); + auto &req = downstream->request(); // Although, we deprecated minor version from HTTP/2, we supply @@ -472,6 +474,7 @@ int on_frame_recv_callback(nghttp2_session *session, const nghttp2_frame *frame, verbose_on_frame_recv_callback(session, frame, user_data); } auto upstream = static_cast(user_data); + auto handler = upstream->get_client_handler(); switch (frame->hd.type) { case NGHTTP2_DATA: { @@ -505,6 +508,8 @@ int on_frame_recv_callback(nghttp2_session *session, const nghttp2_frame *frame, if (frame->headers.cat == NGHTTP2_HCAT_REQUEST) { downstream->reset_upstream_rtimer(); + handler->stop_read_timer(); + return upstream->on_request_headers(downstream, frame); } @@ -1506,8 +1511,6 @@ int Http2Upstream::error_reply(Downstream *downstream, void Http2Upstream::add_pending_downstream( std::unique_ptr downstream) { downstream_queue_.add_pending(std::move(downstream)); - - handler_->stop_read_timer(); } void Http2Upstream::remove_downstream(Downstream *downstream) { diff --git a/src/shrpx_https_upstream.cc b/src/shrpx_https_upstream.cc index 3ca61d9b..db4aee92 100644 --- a/src/shrpx_https_upstream.cc +++ b/src/shrpx_https_upstream.cc @@ -76,7 +76,7 @@ int htp_msg_begin(http_parser *htp) { upstream->attach_downstream(std::move(downstream)); - handler->stop_read_timer(); + handler->repeat_read_timer(); return 0; } @@ -292,6 +292,8 @@ int htp_hdrs_completecb(http_parser *htp) { req.connection_close = !http_should_keep_alive(htp); + handler->stop_read_timer(); + auto method = req.method; if (LOG_ENABLED(INFO)) {