From 3f27bd3eba7ce4aeda41ea6e8a9c43ef09f3a372 Mon Sep 17 00:00:00 2001 From: Roy Jacobson Date: Mon, 12 Jun 2023 16:28:03 +0200 Subject: [PATCH] Fix crash on shutdown from #1388 (#1399) My recent PR accesses Connection->cc_ on shutdown, but sometimes it's a null pointer. Make it optional. --- src/facade/dragonfly_connection.cc | 2 ++ src/facade/dragonfly_connection.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/facade/dragonfly_connection.cc b/src/facade/dragonfly_connection.cc index 37a991910..2909cf6bd 100644 --- a/src/facade/dragonfly_connection.cc +++ b/src/facade/dragonfly_connection.cc @@ -838,6 +838,8 @@ void Connection::ShutdownThreadLocal() { } bool Connection::IsCurrentlyDispatching() const { + if (!cc_) + return false; return cc_->async_dispatch || cc_->sync_dispatch; } diff --git a/src/facade/dragonfly_connection.h b/src/facade/dragonfly_connection.h index 20a1e0fde..baa95d0ee 100644 --- a/src/facade/dragonfly_connection.h +++ b/src/facade/dragonfly_connection.h @@ -233,6 +233,8 @@ class Connection : public util::Connection { Phase phase_; std::string name_; + // A pointer to the ConnectionContext object if it exists. Some connections (like http + // requests) don't have it. std::unique_ptr cc_; unsigned parser_error_ = 0;