From c999785c4ccb7aa29e0f21f2e0e586a1774c7f7e Mon Sep 17 00:00:00 2001 From: Luke Ye Date: Tue, 26 Sep 2023 13:56:15 -0700 Subject: [PATCH] Throw instead of segv in external connection construction due to destroyed thread pool singleton Reviewed By: ghostonhuang Differential Revision: D49647234 fbshipit-source-id: 6b939b85d4171e191e92e8940793edc38ce346ee --- .../lib/carbon/connection/ExternalCarbonConnectionImpl-inl.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mcrouter/lib/carbon/connection/ExternalCarbonConnectionImpl-inl.h b/mcrouter/lib/carbon/connection/ExternalCarbonConnectionImpl-inl.h index 36de3ee8b..3bea8f086 100644 --- a/mcrouter/lib/carbon/connection/ExternalCarbonConnectionImpl-inl.h +++ b/mcrouter/lib/carbon/connection/ExternalCarbonConnectionImpl-inl.h @@ -248,6 +248,10 @@ class Impl { facebook::memcache::ConnectionOptions connectionOptions, ExternalCarbonConnectionImplOptions options) { auto pool = detail::ThreadPool::getInstance(); + if (!pool) { + throw CarbonConnectionException( + "Failed to init Impl due to Singleton was destroyed!"); + } auto info = pool->createClient(connectionOptions, options); client_ = info.first;