From 8cb92fc277b9659b99ec410cb9f4aa39d35986cb Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Wed, 31 Jul 2013 22:14:25 +0900 Subject: [PATCH] nghttpx: Handle error from Upstream::resume_read in upgrade code --- src/shrpx_http_downstream_connection.cc | 5 ++++- src/shrpx_spdy_session.cc | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/shrpx_http_downstream_connection.cc b/src/shrpx_http_downstream_connection.cc index 948d393b..b86efced 100644 --- a/src/shrpx_http_downstream_connection.cc +++ b/src/shrpx_http_downstream_connection.cc @@ -367,7 +367,10 @@ int htp_hdrs_completecb(http_parser *htp) if(downstream->get_upgraded()) { // Upgrade complete, read until EOF in both ends - downstream->get_upstream()->resume_read(SHRPX_MSG_BLOCK, downstream); + if(downstream->get_upstream()->resume_read(SHRPX_MSG_BLOCK, + downstream) != 0) { + return -1; + } downstream->set_request_state(Downstream::HEADER_COMPLETE); if(LOG_ENABLED(INFO)) { LOG(INFO) << "HTTP upgrade success. stream_id=" diff --git a/src/shrpx_spdy_session.cc b/src/shrpx_spdy_session.cc index 647e1820..0f0f0110 100644 --- a/src/shrpx_spdy_session.cc +++ b/src/shrpx_spdy_session.cc @@ -818,7 +818,11 @@ void on_frame_recv_callback if(downstream->get_upgraded()) { downstream->set_response_connection_close(true); // On upgrade sucess, both ends can send data - upstream->resume_read(SHRPX_MSG_BLOCK, downstream); + if(upstream->resume_read(SHRPX_MSG_BLOCK, downstream) != 0) { + // If resume_read fails, just drop connection. Not ideal. + delete upstream->get_client_handler(); + return; + } downstream->set_request_state(Downstream::HEADER_COMPLETE); if(LOG_ENABLED(INFO)) { SSLOG(INFO, spdy) << "HTTP upgrade success. stream_id="