From d83949bc88c90866e705c588ca5233dd5192cf10 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Mon, 21 Nov 2016 22:43:23 +0900 Subject: [PATCH] asio: server: Call on_close callback on connection close --- src/asio_server_http2_handler.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/asio_server_http2_handler.cc b/src/asio_server_http2_handler.cc index 98018077..0e64def3 100644 --- a/src/asio_server_http2_handler.cc +++ b/src/asio_server_http2_handler.cc @@ -249,7 +249,15 @@ http2_handler::http2_handler(boost::asio::io_service &io_service, tstamp_cached_(time(nullptr)), formatted_date_(util::http_date(tstamp_cached_)) {} -http2_handler::~http2_handler() { nghttp2_session_del(session_); } +http2_handler::~http2_handler() { + for (auto &p : streams_) { + auto &strm = p.second; + strm->response().impl().call_on_close(NGHTTP2_INTERNAL_ERROR); + close_stream(strm->get_stream_id()); + } + + nghttp2_session_del(session_); +} const std::string &http2_handler::http_date() { auto t = time(nullptr);