nghttpx: Fix handing stream after connection check was failed

This commit is contained in:
Tatsuhiro Tsujikawa 2016-03-27 15:53:26 +09:00
parent d9a2ff278c
commit 2cee80acf0
1 changed files with 8 additions and 10 deletions

View File

@ -202,7 +202,7 @@ Http2Session::Http2Session(struct ev_loop *loop, SSL_CTX *ssl_ctx,
} }
Http2Session::~Http2Session() { Http2Session::~Http2Session() {
disconnect(); disconnect(true);
if (in_freelist()) { if (in_freelist()) {
if (LOG_ENABLED(INFO)) { if (LOG_ENABLED(INFO)) {
@ -243,20 +243,17 @@ int Http2Session::disconnect(bool hard) {
connection_check_state_ = CONNECTION_CHECK_NONE; connection_check_state_ = CONNECTION_CHECK_NONE;
state_ = DISCONNECTED; state_ = DISCONNECTED;
// Delete all client handler associated to Downstream. When deleting // When deleting Http2DownstreamConnection, it calls this object's
// Http2DownstreamConnection, it calls this object's
// remove_downstream_connection(). The multiple // remove_downstream_connection(). The multiple
// Http2DownstreamConnection objects belong to the same // Http2DownstreamConnection objects belong to the same
// ClientHandler object. So first dump ClientHandler objects. We // ClientHandler object. So first dump ClientHandler objects.
// want to allow creating new pending Http2DownstreamConnection with //
// this object. In order to achieve this, we first swap dconns_ and // We allow creating new pending Http2DownstreamConnection with this
// streams_. Upstream::on_downstream_reset() may add // object. Upstream::on_downstream_reset() may add
// Http2DownstreamConnection. // Http2DownstreamConnection.
auto dconns = std::move(dconns_);
auto streams = std::move(streams_);
std::set<ClientHandler *> handlers; std::set<ClientHandler *> handlers;
for (auto dc = dconns.head; dc; dc = dc->dlnext) { for (auto dc = dconns_.head; dc; dc = dc->dlnext) {
if (!dc->get_client_handler()) { if (!dc->get_client_handler()) {
continue; continue;
} }
@ -268,6 +265,7 @@ int Http2Session::disconnect(bool hard) {
} }
} }
auto streams = std::move(streams_);
for (auto s = streams.head; s;) { for (auto s = streams.head; s;) {
auto next = s->dlnext; auto next = s->dlnext;
delete s; delete s;