From da36fc395353f2e1189f83dd825ef67283fbfecc Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Wed, 27 Feb 2013 22:55:44 +0900 Subject: [PATCH] shrpx: Fix WINDOW_UPDATE may block until SpdyUpstream::send() spdy_data_read_callback in SpdyDownstreamConnection calls SpdyUpstream::resume_read() which submits WINDOW_UPDATE, but after that they are not call SpdyUpstream::send(). This means that if no pending outgoing data in upstream, then WINDOW_UPDATE is blocked until SpdyUpstream::send() from somewhere. This change adds SpdyUpstream::send() to resume_read() so that WINDOW_UPDATE is not blocked. --- src/shrpx_spdy_downstream_connection.cc | 5 +++++ src/shrpx_spdy_upstream.cc | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/shrpx_spdy_downstream_connection.cc b/src/shrpx_spdy_downstream_connection.cc index f836706b..29dca1ca 100644 --- a/src/shrpx_spdy_downstream_connection.cc +++ b/src/shrpx_spdy_downstream_connection.cc @@ -190,6 +190,11 @@ ssize_t spdy_data_read_callback(spdylay_session *session, // In this case, downstream may be deleted. return SPDYLAY_ERR_DEFERRED; } + // Check dconn is still alive because Upstream::resume_read() + // may delete downstream which will delete dconn. + if(sd->dconn == 0) { + return SPDYLAY_ERR_DEFERRED; + } if(evbuffer_get_length(body) == 0) { return SPDYLAY_ERR_DEFERRED; } diff --git a/src/shrpx_spdy_upstream.cc b/src/shrpx_spdy_upstream.cc index 5193c809..ad602285 100644 --- a/src/shrpx_spdy_upstream.cc +++ b/src/shrpx_spdy_upstream.cc @@ -898,7 +898,7 @@ int SpdyUpstream::resume_read(IOCtrlReason reason, Downstream *downstream) window_update(downstream); } } - return 0; + return send(); } } // namespace shrpx