diff options
author | Gabriel Marks <gabriel.marks@mongodb.com> | 2022-05-06 19:41:52 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-05-06 22:56:33 +0000 |
commit | b08da7fbbcf6661ecb63a07b76dceb7a206240f9 (patch) | |
tree | 068b8c2a1b4ec047da5871a91621dada15b08da5 /src/mongo/util/net/http_client_curl.cpp | |
parent | b3515cdffb30aec1d34cd7faefdd92efec001160 (diff) | |
download | mongo-b08da7fbbcf6661ecb63a07b76dceb7a206240f9.tar.gz |
SERVER-66087 Move curlLibraryManager.initialize() to global initializer
Diffstat (limited to 'src/mongo/util/net/http_client_curl.cpp')
-rw-r--r-- | src/mongo/util/net/http_client_curl.cpp | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/src/mongo/util/net/http_client_curl.cpp b/src/mongo/util/net/http_client_curl.cpp index 5481a062e9d..fa1834c8bde 100644 --- a/src/mongo/util/net/http_client_curl.cpp +++ b/src/mongo/util/net/http_client_curl.cpp @@ -108,18 +108,8 @@ public: } Status initialize() { - auto status = _initializeGlobal(); - if (!status.isOK()) { - return status; - } - - return Status::OK(); - } - -private: - Status _initializeGlobal() { if (_initialized) { - return Status::OK(); + return {ErrorCodes::AlreadyInitialized, "CurlLibraryManager already initialized."}; } CURLcode ret = curl_global_init(CURL_GLOBAL_ALL); @@ -137,6 +127,10 @@ private: return Status::OK(); } + bool isInitialized() const { + return _initialized; + } + private: bool _initialized = false; @@ -712,17 +706,17 @@ public: } std::unique_ptr<HttpClient> create() final { - uassertStatusOK(curlLibraryManager.initialize()); + invariant(curlLibraryManager.isInitialized()); return std::make_unique<CurlHttpClient>(HttpConnectionPool::kUse); } std::unique_ptr<HttpClient> createWithoutConnectionPool() final { - uassertStatusOK(curlLibraryManager.initialize()); + invariant(curlLibraryManager.isInitialized()); return std::make_unique<CurlHttpClient>(HttpConnectionPool::kDoNotUse); } BSONObj getServerStatus() final { - + invariant(curlLibraryManager.isInitialized()); BSONObjBuilder info; info.append("type", "curl"); @@ -747,10 +741,11 @@ public: } // namespace -// Transitional API used by blockstore to trigger libcurl init -// until it's been migrated to use the HTTPClient API. -Status curlLibraryManager_initialize() { - return curlLibraryManager.initialize(); +MONGO_INITIALIZER_GENERAL(CurlLibraryManager, + (), + ("BeginStartupOptionParsing", "NativeSaslClientContext")) +(InitializerContext* context) { + uassertStatusOK(curlLibraryManager.initialize()); } |