Delete downstream if SPDY stream has been already closed

This commit is contained in:
Tatsuhiro Tsujikawa 2012-06-05 22:46:47 +09:00
parent e8cefa9238
commit 67669bf3ca
1 changed files with 10 additions and 13 deletions

View File

@ -272,18 +272,17 @@ void spdy_downstream_readcb(bufferevent *bev, void *ptr)
Downstream *downstream = reinterpret_cast<Downstream*>(ptr); Downstream *downstream = reinterpret_cast<Downstream*>(ptr);
SpdyUpstream *upstream; SpdyUpstream *upstream;
upstream = static_cast<SpdyUpstream*>(downstream->get_upstream()); upstream = static_cast<SpdyUpstream*>(downstream->get_upstream());
int rv = downstream->parse_http_response(); // If upstream SPDY stream was closed, we just close downstream,
if(rv == 0) { // because there is no consumer now.
if(downstream->get_request_state() == Downstream::STREAM_CLOSED && if(downstream->get_request_state() == Downstream::STREAM_CLOSED) {
downstream->get_response_state() == Downstream::MSG_COMPLETE) { upstream->remove_downstream(downstream);
upstream->get_downstream_queue()->remove(downstream);
delete downstream; delete downstream;
} else { return;
upstream->send();
} }
} else { int rv = downstream->parse_http_response();
if(rv != 0) {
if(ENABLE_LOG) { if(ENABLE_LOG) {
LOG(INFO) << "<downstream> http parser failure"; LOG(INFO) << "Downstream HTTP parser failure";
} }
if(downstream->get_response_state() == Downstream::HEADER_COMPLETE) { if(downstream->get_response_state() == Downstream::HEADER_COMPLETE) {
upstream->rst_stream(downstream, SPDYLAY_INTERNAL_ERROR); upstream->rst_stream(downstream, SPDYLAY_INTERNAL_ERROR);
@ -291,10 +290,8 @@ void spdy_downstream_readcb(bufferevent *bev, void *ptr)
upstream->error_reply(downstream, 502); upstream->error_reply(downstream, 502);
} }
downstream->set_response_state(Downstream::MSG_COMPLETE); downstream->set_response_state(Downstream::MSG_COMPLETE);
upstream->send();
// upstream->remove_downstream(downstream);
// delete downstream;
} }
upstream->send();
} }
} // namespace } // namespace