Commit d0bf2474 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

nghttpx: Refactor graceful shutdown in Http2Upstream

Instead of using bool flag, just stop prepare watcher.
parent 9237d30e
...@@ -787,23 +787,25 @@ void Http2Upstream::submit_goaway() { ...@@ -787,23 +787,25 @@ void Http2Upstream::submit_goaway() {
void Http2Upstream::check_shutdown() { void Http2Upstream::check_shutdown() {
int rv; int rv;
if (shutdown_handled_) {
auto worker = handler_->get_worker();
if (!worker->get_graceful_shutdown()) {
return; return;
} }
auto worker = handler_->get_worker(); ev_prepare_stop(handler_->get_loop(), &prep_);
if (worker->get_graceful_shutdown()) { rv = nghttp2_submit_shutdown_notice(session_);
shutdown_handled_ = true; if (rv != 0) {
rv = nghttp2_submit_shutdown_notice(session_); ULOG(FATAL, this) << "nghttp2_submit_shutdown_notice() failed: "
if (rv != 0) { << nghttp2_strerror(rv);
ULOG(FATAL, this) << "nghttp2_submit_shutdown_notice() failed: " return;
<< nghttp2_strerror(rv);
return;
}
handler_->signal_write();
ev_timer_start(handler_->get_loop(), &shutdown_timer_);
} }
handler_->signal_write();
ev_timer_start(handler_->get_loop(), &shutdown_timer_);
} }
nghttp2_session_callbacks *create_http2_upstream_callbacks() { nghttp2_session_callbacks *create_http2_upstream_callbacks() {
...@@ -870,9 +872,7 @@ Http2Upstream::Http2Upstream(ClientHandler *handler) ...@@ -870,9 +872,7 @@ Http2Upstream::Http2Upstream(ClientHandler *handler)
downstream_queue_(downstream_queue_size(handler->get_worker()), downstream_queue_(downstream_queue_size(handler->get_worker()),
!get_config()->http2_proxy), !get_config()->http2_proxy),
handler_(handler), handler_(handler),
session_(nullptr), session_(nullptr) {
shutdown_handled_(false) {
int rv; int rv;
auto &http2conf = get_config()->http2; auto &http2conf = get_config()->http2;
......
...@@ -132,7 +132,6 @@ private: ...@@ -132,7 +132,6 @@ private:
ClientHandler *handler_; ClientHandler *handler_;
nghttp2_session *session_; nghttp2_session *session_;
bool flow_control_; bool flow_control_;
bool shutdown_handled_;
}; };
nghttp2_session_callbacks *create_http2_upstream_callbacks(); nghttp2_session_callbacks *create_http2_upstream_callbacks();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment