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.
This commit is contained in:
Roy Jacobson 2023-06-12 16:28:03 +02:00 committed by GitHub
parent e6a8ec8598
commit 3f27bd3eba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 0 deletions

View file

@ -838,6 +838,8 @@ void Connection::ShutdownThreadLocal() {
}
bool Connection::IsCurrentlyDispatching() const {
if (!cc_)
return false;
return cc_->async_dispatch || cc_->sync_dispatch;
}

View file

@ -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<ConnectionContext> cc_;
unsigned parser_error_ = 0;