From 629f1e6f0f19c6030c8a8a9e3a061bbd71d6898f Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Wed, 18 May 2016 01:21:23 +0900 Subject: [PATCH] nghttpx: Add connection: close to mruby response in graceful shutdown period --- src/shrpx_https_upstream.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/shrpx_https_upstream.cc b/src/shrpx_https_upstream.cc index ed22f473..86195019 100644 --- a/src/shrpx_https_upstream.cc +++ b/src/shrpx_https_upstream.cc @@ -806,7 +806,16 @@ int HttpsUpstream::send_reply(Downstream *downstream, const uint8_t *body, auto &balloc = downstream->get_block_allocator(); auto connection_close = false; - if (req.http_major <= 0 || (req.http_major == 1 && req.http_minor == 0)) { + + auto worker = handler_->get_worker(); + + if (worker->get_graceful_shutdown()) { + resp.fs.add_header_token(StringRef::from_lit("connection"), + StringRef::from_lit("close"), false, + http2::HD_CONNECTION); + connection_close = true; + } else if (req.http_major <= 0 || + (req.http_major == 1 && req.http_minor == 0)) { connection_close = true; } else { auto c = resp.fs.header(http2::HD_CONNECTION);