From 2cee80acf03386ca4de8bba0e9e5aa771c3ade49 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sun, 27 Mar 2016 15:53:26 +0900 Subject: [PATCH] nghttpx: Fix handing stream after connection check was failed --- src/shrpx_http2_session.cc | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/shrpx_http2_session.cc b/src/shrpx_http2_session.cc index 7ad2af65..38716faa 100644 --- a/src/shrpx_http2_session.cc +++ b/src/shrpx_http2_session.cc @@ -202,7 +202,7 @@ Http2Session::Http2Session(struct ev_loop *loop, SSL_CTX *ssl_ctx, } Http2Session::~Http2Session() { - disconnect(); + disconnect(true); if (in_freelist()) { if (LOG_ENABLED(INFO)) { @@ -243,20 +243,17 @@ int Http2Session::disconnect(bool hard) { connection_check_state_ = CONNECTION_CHECK_NONE; state_ = DISCONNECTED; - // Delete all client handler associated to Downstream. When deleting - // Http2DownstreamConnection, it calls this object's + // When deleting Http2DownstreamConnection, it calls this object's // remove_downstream_connection(). The multiple // Http2DownstreamConnection objects belong to the same - // ClientHandler object. So first dump ClientHandler objects. We - // want to allow creating new pending Http2DownstreamConnection with - // this object. In order to achieve this, we first swap dconns_ and - // streams_. Upstream::on_downstream_reset() may add + // ClientHandler object. So first dump ClientHandler objects. + // + // We allow creating new pending Http2DownstreamConnection with this + // object. Upstream::on_downstream_reset() may add // Http2DownstreamConnection. - auto dconns = std::move(dconns_); - auto streams = std::move(streams_); std::set handlers; - for (auto dc = dconns.head; dc; dc = dc->dlnext) { + for (auto dc = dconns_.head; dc; dc = dc->dlnext) { if (!dc->get_client_handler()) { continue; } @@ -268,6 +265,7 @@ int Http2Session::disconnect(bool hard) { } } + auto streams = std::move(streams_); for (auto s = streams.head; s;) { auto next = s->dlnext; delete s;