From 912d6e43547faceaa62e3ed3983bd964a46e0e5e Mon Sep 17 00:00:00 2001 From: Ali Beyad Date: Thu, 9 Jan 2025 16:18:41 -0500 Subject: [PATCH 1/9] logger: Create only one Context per process for mobile The Logger::Context operates as a stack. When a new one is created, it becomes the active Context. When it gets destroyed, the destructor pops the previous Context as the currently active one. This can lead to lifetime bugs in Envoy Mobile, if multiple engines are created and the destruction of those engines lead to indeterminate destruction of the Logger::Context objects. In this commit, the behavior is changed so that the Logger::Context initialization is done by the external caller, not inside StrippedMainBase as previously done. This allows the caller, in this case, Envoy Mobile, to ensure only one Logger::Context is ever created, circumventing any potential issues on Context destruction with popping the previously saved context. Signed-off-by: Ali Beyad --- mobile/library/common/BUILD | 2 + mobile/library/common/engine_common.cc | 10 +++-- mobile/library/common/internal_engine.cc | 18 ++++++++- mobile/library/common/internal_engine.h | 4 +- source/exe/main_common.cc | 15 ++++++-- source/exe/main_common.h | 4 ++ source/exe/stripped_main_base.cc | 47 ++++++++++-------------- source/exe/stripped_main_base.h | 18 +++++---- 8 files changed, 73 insertions(+), 45 deletions(-) diff --git a/mobile/library/common/BUILD b/mobile/library/common/BUILD index 1990b609dc0d..4aaf2a4e1276 100644 --- a/mobile/library/common/BUILD +++ b/mobile/library/common/BUILD @@ -36,7 +36,9 @@ envoy_cc_library( "//library/common/types:c_types_lib", "@envoy//envoy/server:lifecycle_notifier_interface", "@envoy//envoy/stats:stats_interface", + "@envoy//source/common/common:minimal_logger_lib", "@envoy//source/common/common:thread_impl_lib_posix", + "@envoy//source/common/common:thread_lib", "@envoy//source/common/common:utility_lib", "@envoy//source/common/runtime:runtime_lib", "@envoy_build_config//:extension_registry", diff --git a/mobile/library/common/engine_common.cc b/mobile/library/common/engine_common.cc index 0f0746c431f7..bb7b138f1fa0 100644 --- a/mobile/library/common/engine_common.cc +++ b/mobile/library/common/engine_common.cc @@ -100,10 +100,12 @@ EngineCommon::EngineCommon(std::shared_ptr options) : op }; // `set_new_handler` is false because the application using Envoy Mobile should decide how to // handle `new` memory allocation failures. - base_ = std::make_unique( - *options_, real_time_system_, default_listener_hooks_, prod_component_factory_, - std::make_unique(), std::make_unique(), nullptr, - create_instance, /*set_new_handler=*/false); + std::unique_ptr random_generator = + std::make_unique(); + base_ = std::make_unique(*options_, prod_component_factory_, + std::make_unique(), *random_generator); + base_->init(real_time_system_, default_listener_hooks_, std::move(random_generator), nullptr, + create_instance); // Disabling signal handling in the options makes it so that the server's event dispatcher _does // not_ listen for termination signals such as SIGTERM, SIGINT, etc // (https://github.com/envoyproxy/envoy/blob/048f4231310fbbead0cbe03d43ffb4307fff0517/source/server/server.cc#L519). diff --git a/mobile/library/common/internal_engine.cc b/mobile/library/common/internal_engine.cc index 53e9f673317e..dc4ccdbdf1a5 100644 --- a/mobile/library/common/internal_engine.cc +++ b/mobile/library/common/internal_engine.cc @@ -4,6 +4,8 @@ #include "source/common/api/os_sys_calls_impl.h" #include "source/common/common/lock_guard.h" +#include "source/common/common/logger.h" +#include "source/common/common/thread.h" #include "source/common/common/utility.h" #include "source/common/http/http_server_properties_cache_manager_impl.h" #include "source/common/network/io_socket_handle_impl.h" @@ -19,6 +21,17 @@ constexpr absl::Duration ENGINE_RUNNING_TIMEOUT = absl::Seconds(30); // Google DNS address used for IPv6 probes. constexpr absl::string_view IPV6_PROBE_ADDRESS = "2001:4860:4860::8888"; constexpr uint32_t IPV6_PROBE_PORT = 53; + +// There is only one shared static Logger::Context instance for all Envoy Mobile engines. +// This helps avoid issues on Logger::Context destruction when the previous saved context +// could be activated in a thread-unsafe manner. +void initOnceLoggerContext(const OptionsImplBase& options) { + static Thread::MutexBasicLockable* log_lock = new Thread::MutexBasicLockable(); + static Logger::Context* context = + new Logger::Context(options.logLevel(), options.logFormat(), *log_lock, + options.logFormatEscaped(), options.enableFineGrainLogging()); + UNREFERENCED_PARAMETER(context); +} } // namespace static std::atomic current_stream_handle_{0}; @@ -90,7 +103,8 @@ envoy_status_t InternalEngine::cancelStream(envoy_stream_t stream) { // This function takes a `std::shared_ptr` instead of `std::unique_ptr` because `std::function` is a // copy-constructible type, so it's not possible to move capture `std::unique_ptr` with // `std::function`. -envoy_status_t InternalEngine::run(std::shared_ptr options) { +envoy_status_t InternalEngine::run(std::shared_ptr options) { + initOnceLoggerContext(*options); Thread::Options thread_options; thread_options.priority_ = thread_priority_; main_thread_ = thread_factory_->createThread([this, options]() mutable -> void { main(options); }, @@ -98,7 +112,7 @@ envoy_status_t InternalEngine::run(std::shared_ptr optio return (main_thread_ != nullptr) ? ENVOY_SUCCESS : ENVOY_FAILURE; } -envoy_status_t InternalEngine::main(std::shared_ptr options) { +envoy_status_t InternalEngine::main(std::shared_ptr options) { // Using unique_ptr ensures main_common's lifespan is strictly scoped to this function. std::unique_ptr main_common; { diff --git a/mobile/library/common/internal_engine.h b/mobile/library/common/internal_engine.h index eec47a4916d9..1382ec672bf2 100644 --- a/mobile/library/common/internal_engine.h +++ b/mobile/library/common/internal_engine.h @@ -41,7 +41,7 @@ class InternalEngine : public Logger::Loggable { * Run the engine with the provided options. * @param options, the Envoy options, including the Bootstrap configuration and log level. */ - envoy_status_t run(std::shared_ptr options); + envoy_status_t run(std::shared_ptr options); /** * Immediately terminate the engine, if running. Calling this function when @@ -170,7 +170,7 @@ class InternalEngine : public Logger::Loggable { std::unique_ptr event_tracker, absl::optional thread_priority, Thread::PosixThreadFactoryPtr thread_factory); - envoy_status_t main(std::shared_ptr options); + envoy_status_t main(std::shared_ptr options); static void logInterfaces(absl::string_view event, std::vector& interfaces); /** Returns true if there is IPv6 connectivity. */ diff --git a/source/exe/main_common.cc b/source/exe/main_common.cc index 87b3342f3335..ea9c4e6d0b35 100644 --- a/source/exe/main_common.cc +++ b/source/exe/main_common.cc @@ -55,14 +55,23 @@ MainCommonBase::MainCommonBase(const Server::Options& options, Event::TimeSystem std::unique_ptr platform_impl, std::unique_ptr&& random_generator, std::unique_ptr process_context) - : StrippedMainBase(options, time_system, listener_hooks, component_factory, - std::move(platform_impl), std::move(random_generator), - std::move(process_context), createFunction()) + : StrippedMainBase(options, component_factory, std::move(platform_impl), *random_generator) #ifdef ENVOY_ADMIN_FUNCTIONALITY , shared_response_set_(std::make_shared()) #endif { + if (options.mode() == Server::Mode::Serve) { + // Provide consistent behavior for out-of-memory, regardless of whether it occurs in a + // try/catch block or not. + std::set_new_handler([]() { PANIC("out of memory"); }); + } + + logging_context_ = std::make_unique( + options_.logLevel(), options_.logFormat(), restarter_->logLock(), options_.logFormatEscaped(), + options_.mode() == Server::Mode::Validate ? false : options_.enableFineGrainLogging()); + init(time_system, listener_hooks, std::move(random_generator), std::move(process_context), + createFunction()); } bool MainCommonBase::run() { diff --git a/source/exe/main_common.h b/source/exe/main_common.h index 500f293ce7f1..1d7b9d72069e 100644 --- a/source/exe/main_common.h +++ b/source/exe/main_common.h @@ -37,7 +37,11 @@ class MainCommonBase : public StrippedMainBase { bool run(); +private: + std::unique_ptr logging_context_; + #ifdef ENVOY_ADMIN_FUNCTIONALITY +public: using AdminRequestFn = std::function; diff --git a/source/exe/stripped_main_base.cc b/source/exe/stripped_main_base.cc index 6d6321f89049..fac588bf4a78 100644 --- a/source/exe/stripped_main_base.cc +++ b/source/exe/stripped_main_base.cc @@ -41,18 +41,15 @@ Runtime::LoaderPtr ProdComponentFactory::createRuntime(Server::Instance& server, return Server::InstanceUtil::createRuntime(server, config); } -StrippedMainBase::StrippedMainBase(const Server::Options& options, Event::TimeSystem& time_system, - ListenerHooks& listener_hooks, +StrippedMainBase::StrippedMainBase(const Server::Options& options, Server::ComponentFactory& component_factory, std::unique_ptr platform_impl, - std::unique_ptr&& random_generator, - std::unique_ptr process_context, - CreateInstanceFunction create_instance, bool set_new_handler) + Random::RandomGenerator& random_generator) : platform_impl_(std::move(platform_impl)), options_(options), component_factory_(component_factory), stats_allocator_(symbol_table_) { // Process the option to disable extensions as early as possible, // before we do any configuration loading. - OptionsImplBase::disableExtensions(options.disabledExtensions()); + OptionsImplBase::disableExtensions(options_.disabledExtensions()); // Enable core dumps as early as possible. if (options_.coreDumpEnabled()) { @@ -66,37 +63,33 @@ StrippedMainBase::StrippedMainBase(const Server::Options& options, Event::TimeSy switch (options_.mode()) { case Server::Mode::InitOnly: - case Server::Mode::Serve: { - configureHotRestarter(*random_generator); - + case Server::Mode::Serve: + configureHotRestarter(random_generator); tls_ = std::make_unique(); - Thread::BasicLockable& log_lock = restarter_->logLock(); - Thread::BasicLockable& access_log_lock = restarter_->accessLogLock(); - logging_context_ = std::make_unique(options_.logLevel(), options_.logFormat(), - log_lock, options_.logFormatEscaped(), - options_.enableFineGrainLogging()); + stats_store_ = std::make_unique(stats_allocator_); + break; + case Server::Mode::Validate: + restarter_ = std::make_unique(); + break; + } +} +void StrippedMainBase::init(Event::TimeSystem& time_system, ListenerHooks& listener_hooks, + std::unique_ptr&& random_generator, + std::unique_ptr process_context, + CreateInstanceFunction create_instance) { + switch (options_.mode()) { + case Server::Mode::InitOnly: + case Server::Mode::Serve: { configureComponentLogLevels(); - if (set_new_handler) { - // Provide consistent behavior for out-of-memory, regardless of whether it occurs in a - // try/catch block or not. - std::set_new_handler([]() { PANIC("out of memory"); }); - } - - stats_store_ = std::make_unique(stats_allocator_); - server_ = create_instance(*init_manager_, options_, time_system, listener_hooks, *restarter_, - *stats_store_, access_log_lock, component_factory, + *stats_store_, restarter_->accessLogLock(), component_factory_, std::move(random_generator), *tls_, platform_impl_->threadFactory(), platform_impl_->fileSystem(), std::move(process_context), nullptr); break; } case Server::Mode::Validate: - restarter_ = std::make_unique(); - logging_context_ = - std::make_unique(options_.logLevel(), options_.logFormat(), - restarter_->logLock(), options_.logFormatEscaped()); process_context_ = std::move(process_context); break; } diff --git a/source/exe/stripped_main_base.h b/source/exe/stripped_main_base.h index eb6a632b4ad4..9f12b4778c3d 100644 --- a/source/exe/stripped_main_base.h +++ b/source/exe/stripped_main_base.h @@ -47,13 +47,18 @@ class StrippedMainBase { static std::string hotRestartVersion(bool hot_restart_enabled); // Consumer must guarantee that all passed references are alive until this object is - // destructed. - StrippedMainBase(const Server::Options& options, Event::TimeSystem& time_system, - ListenerHooks& listener_hooks, Server::ComponentFactory& component_factory, + // destructed, except for `random_generator` which only needs to be alive until the constructor + // completes execution. + StrippedMainBase(const Server::Options& options, Server::ComponentFactory& component_factory, std::unique_ptr platform_impl, - std::unique_ptr&& random_generator, - std::unique_ptr process_context, - CreateInstanceFunction create_instance, bool set_new_handler = true); + Random::RandomGenerator& random_generator); + + // Initialize the Envoy server instance. Must be called prior to any other method to use the + // server. Separated from the constructor to allow for globals to be initialized first. + void init(Event::TimeSystem& time_system, ListenerHooks& listener_hooks, + std::unique_ptr&& random_generator, + std::unique_ptr process_context, + CreateInstanceFunction create_instance); void runServer() { ASSERT(options_.mode() == Server::Mode::Serve); @@ -78,7 +83,6 @@ class StrippedMainBase { ThreadLocal::InstanceImplPtr tls_; std::unique_ptr restarter_; Stats::ThreadLocalStoreImplPtr stats_store_; - std::unique_ptr logging_context_; std::unique_ptr init_manager_{std::make_unique("Server")}; std::unique_ptr server_; From 7fbdd10bcdf310f5fc98a9ee724aebe2602743f2 Mon Sep 17 00:00:00 2001 From: Ali Beyad Date: Thu, 23 Jan 2025 06:29:21 +0000 Subject: [PATCH 2/9] format Signed-off-by: Ali Beyad --- source/exe/main_common.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/exe/main_common.cc b/source/exe/main_common.cc index ea9c4e6d0b35..75099c6ee0c0 100644 --- a/source/exe/main_common.cc +++ b/source/exe/main_common.cc @@ -62,9 +62,9 @@ MainCommonBase::MainCommonBase(const Server::Options& options, Event::TimeSystem #endif { if (options.mode() == Server::Mode::Serve) { - // Provide consistent behavior for out-of-memory, regardless of whether it occurs in a - // try/catch block or not. - std::set_new_handler([]() { PANIC("out of memory"); }); + // Provide consistent behavior for out-of-memory, regardless of whether it occurs in a + // try/catch block or not. + std::set_new_handler([]() { PANIC("out of memory"); }); } logging_context_ = std::make_unique( From 99fd997ea61b5492cfc1e517f497a6417e7d2024 Mon Sep 17 00:00:00 2001 From: Ali Beyad Date: Fri, 24 Jan 2025 22:32:46 +0000 Subject: [PATCH 3/9] tsan Signed-off-by: Ali Beyad --- source/exe/main_common.h | 3 --- source/exe/stripped_main_base.h | 5 +++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/source/exe/main_common.h b/source/exe/main_common.h index 1d7b9d72069e..3eef14a41cd2 100644 --- a/source/exe/main_common.h +++ b/source/exe/main_common.h @@ -37,9 +37,6 @@ class MainCommonBase : public StrippedMainBase { bool run(); -private: - std::unique_ptr logging_context_; - #ifdef ENVOY_ADMIN_FUNCTIONALITY public: using AdminRequestFn = diff --git a/source/exe/stripped_main_base.h b/source/exe/stripped_main_base.h index 9f12b4778c3d..2a067e88a6f5 100644 --- a/source/exe/stripped_main_base.h +++ b/source/exe/stripped_main_base.h @@ -83,6 +83,11 @@ class StrippedMainBase { ThreadLocal::InstanceImplPtr tls_; std::unique_ptr restarter_; Stats::ThreadLocalStoreImplPtr stats_store_; + // logging_context_ is only used in (some) subclasses, but it must be declared here so that it's + // destructed after the server_. This is necessary because the Server and its threads may log + // during destruction, causing data race issues with the Context's destruction and activation of + // the saved context. + std::unique_ptr logging_context_; std::unique_ptr init_manager_{std::make_unique("Server")}; std::unique_ptr server_; From c407e11a7503582dce8b51e9d5625ee79ab51010 Mon Sep 17 00:00:00 2001 From: Ali Beyad Date: Fri, 24 Jan 2025 22:47:38 +0000 Subject: [PATCH 4/9] fix Signed-off-by: Ali Beyad --- source/exe/main_common.h | 1 - 1 file changed, 1 deletion(-) diff --git a/source/exe/main_common.h b/source/exe/main_common.h index 3eef14a41cd2..500f293ce7f1 100644 --- a/source/exe/main_common.h +++ b/source/exe/main_common.h @@ -38,7 +38,6 @@ class MainCommonBase : public StrippedMainBase { bool run(); #ifdef ENVOY_ADMIN_FUNCTIONALITY -public: using AdminRequestFn = std::function; From 11a79d44791bfaae775049fe6940780868d1a4e5 Mon Sep 17 00:00:00 2001 From: Ali Beyad Date: Sun, 26 Jan 2025 18:30:05 +0000 Subject: [PATCH 5/9] comments Signed-off-by: Ali Beyad --- mobile/library/common/engine_common.cc | 5 +---- mobile/library/common/internal_engine.cc | 8 +++----- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/mobile/library/common/engine_common.cc b/mobile/library/common/engine_common.cc index bb7b138f1fa0..d882c3c5944c 100644 --- a/mobile/library/common/engine_common.cc +++ b/mobile/library/common/engine_common.cc @@ -98,10 +98,7 @@ EngineCommon::EngineCommon(std::shared_ptr options) : op server->initialize(local_address, component_factory); return server; }; - // `set_new_handler` is false because the application using Envoy Mobile should decide how to - // handle `new` memory allocation failures. - std::unique_ptr random_generator = - std::make_unique(); + auto random_generator = std::make_unique(); base_ = std::make_unique(*options_, prod_component_factory_, std::make_unique(), *random_generator); base_->init(real_time_system_, default_listener_hooks_, std::move(random_generator), nullptr, diff --git a/mobile/library/common/internal_engine.cc b/mobile/library/common/internal_engine.cc index dc4ccdbdf1a5..411b530795dd 100644 --- a/mobile/library/common/internal_engine.cc +++ b/mobile/library/common/internal_engine.cc @@ -26,11 +26,9 @@ constexpr uint32_t IPV6_PROBE_PORT = 53; // This helps avoid issues on Logger::Context destruction when the previous saved context // could be activated in a thread-unsafe manner. void initOnceLoggerContext(const OptionsImplBase& options) { - static Thread::MutexBasicLockable* log_lock = new Thread::MutexBasicLockable(); - static Logger::Context* context = - new Logger::Context(options.logLevel(), options.logFormat(), *log_lock, - options.logFormatEscaped(), options.enableFineGrainLogging()); - UNREFERENCED_PARAMETER(context); + Thread::MutexBasicLockable& log_lock = MUTABLE_CONSTRUCT_ON_FIRST_USE(Thread::MutexBasicLockable); + MUTABLE_CONSTRUCT_ON_FIRST_USE(Logger::Context, options.logLevel(), options.logFormat(), log_lock, + options.logFormatEscaped(), options.enableFineGrainLogging()); } } // namespace From 2c8a4246dcb90b54dbe87339ef0934a8b9273f2b Mon Sep 17 00:00:00 2001 From: Ali Beyad Date: Wed, 29 Jan 2025 15:54:35 +0000 Subject: [PATCH 6/9] MobileProcessWide Signed-off-by: Ali Beyad --- mobile/library/common/BUILD | 17 ++++++++++++++++ mobile/library/common/internal_engine.cc | 13 +++++------- mobile/library/common/mobile_process_wide.cc | 13 ++++++++++++ mobile/library/common/mobile_process_wide.h | 21 ++++++++++++++++++++ 4 files changed, 56 insertions(+), 8 deletions(-) create mode 100644 mobile/library/common/mobile_process_wide.cc create mode 100644 mobile/library/common/mobile_process_wide.h diff --git a/mobile/library/common/BUILD b/mobile/library/common/BUILD index 4aaf2a4e1276..968877fd9078 100644 --- a/mobile/library/common/BUILD +++ b/mobile/library/common/BUILD @@ -25,6 +25,7 @@ envoy_cc_library( deps = [ ":engine_common_lib", ":engine_types_lib", + ":mobile_process_wide_lib", "//library/common/bridge:utility_lib", "//library/common/event:provisional_dispatcher_lib", "//library/common/http:client_lib", @@ -93,3 +94,19 @@ envoy_cc_library( "@envoy//source/common/http:header_map_lib", ], ) + +envoy_cc_library( + name = "mobile_process_wide_lib", + hdrs = [ + "mobile_process_wide.h", + ], + srcs = [ + "mobile_process_wide.cc", + ], + repository = "@envoy", + deps = [ + "@envoy//source/common/common:minimal_logger_lib", + "@envoy//source/common/common:thread_lib", + "@envoy//source/server:options_base", + ], +) diff --git a/mobile/library/common/internal_engine.cc b/mobile/library/common/internal_engine.cc index 411b530795dd..3aa97cb9eefb 100644 --- a/mobile/library/common/internal_engine.cc +++ b/mobile/library/common/internal_engine.cc @@ -12,6 +12,7 @@ #include "source/common/runtime/runtime_features.h" #include "absl/synchronization/notification.h" +#include "library/common/mobile_process_wide.h" #include "library/common/network/proxy_api.h" #include "library/common/stats/utility.h" @@ -22,13 +23,9 @@ constexpr absl::Duration ENGINE_RUNNING_TIMEOUT = absl::Seconds(30); constexpr absl::string_view IPV6_PROBE_ADDRESS = "2001:4860:4860::8888"; constexpr uint32_t IPV6_PROBE_PORT = 53; -// There is only one shared static Logger::Context instance for all Envoy Mobile engines. -// This helps avoid issues on Logger::Context destruction when the previous saved context -// could be activated in a thread-unsafe manner. -void initOnceLoggerContext(const OptionsImplBase& options) { - Thread::MutexBasicLockable& log_lock = MUTABLE_CONSTRUCT_ON_FIRST_USE(Thread::MutexBasicLockable); - MUTABLE_CONSTRUCT_ON_FIRST_USE(Logger::Context, options.logLevel(), options.logFormat(), log_lock, - options.logFormatEscaped(), options.enableFineGrainLogging()); +// There is only one shared MobileProcessWide instance for all Envoy Mobile engines. +MobileProcessWide& initOnceMobileProcessWide(const OptionsImplBase& options) { + MUTABLE_CONSTRUCT_ON_FIRST_USE(MobileProcessWide, options); } } // namespace @@ -102,7 +99,7 @@ envoy_status_t InternalEngine::cancelStream(envoy_stream_t stream) { // copy-constructible type, so it's not possible to move capture `std::unique_ptr` with // `std::function`. envoy_status_t InternalEngine::run(std::shared_ptr options) { - initOnceLoggerContext(*options); + initOnceMobileProcessWide(*options); Thread::Options thread_options; thread_options.priority_ = thread_priority_; main_thread_ = thread_factory_->createThread([this, options]() mutable -> void { main(options); }, diff --git a/mobile/library/common/mobile_process_wide.cc b/mobile/library/common/mobile_process_wide.cc new file mode 100644 index 000000000000..f0d3c4ceaf95 --- /dev/null +++ b/mobile/library/common/mobile_process_wide.cc @@ -0,0 +1,13 @@ +#include "library/common/mobile_process_wide.h" + +namespace Envoy { + +MobileProcessWide::MobileProcessWide(const OptionsImplBase& options) { + logging_context_ = std::make_unique(options.logLevel(), options.logFormat(), + log_lock_, options.logFormatEscaped(), + options.enableFineGrainLogging()); +} + +MobileProcessWide::~MobileProcessWide() { logging_context_.reset(nullptr); } + +} // namespace Envoy diff --git a/mobile/library/common/mobile_process_wide.h b/mobile/library/common/mobile_process_wide.h new file mode 100644 index 000000000000..94b954d693fe --- /dev/null +++ b/mobile/library/common/mobile_process_wide.h @@ -0,0 +1,21 @@ +#pragma once + +#include "source/common/common/logger.h" +#include "source/common/common/thread.h" +#include "source/server/options_impl_base.h" + +namespace Envoy { + +// Process-wide lifecycle events for global state for Envoy Mobile. There should only ever be a +// singleton of this class. +class MobileProcessWide { +public: + explicit MobileProcessWide(const OptionsImplBase& options); + ~MobileProcessWide(); + +private: + Thread::MutexBasicLockable log_lock_; + std::unique_ptr logging_context_; +}; + +} // namespace Envoy From 86a86724b462225100a1b83bad5faab312f9c7dc Mon Sep 17 00:00:00 2001 From: Ali Beyad Date: Wed, 29 Jan 2025 16:01:34 +0000 Subject: [PATCH 7/9] format Signed-off-by: Ali Beyad --- mobile/library/common/BUILD | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mobile/library/common/BUILD b/mobile/library/common/BUILD index 968877fd9078..5df532fc8b8a 100644 --- a/mobile/library/common/BUILD +++ b/mobile/library/common/BUILD @@ -97,12 +97,12 @@ envoy_cc_library( envoy_cc_library( name = "mobile_process_wide_lib", - hdrs = [ - "mobile_process_wide.h", - ], srcs = [ "mobile_process_wide.cc", ], + hdrs = [ + "mobile_process_wide.h", + ], repository = "@envoy", deps = [ "@envoy//source/common/common:minimal_logger_lib", From f1c908d49fc9b61daa05746c178a85601046a9af Mon Sep 17 00:00:00 2001 From: Ali Beyad Date: Wed, 29 Jan 2025 16:04:49 +0000 Subject: [PATCH 8/9] fix Signed-off-by: Ali Beyad --- mobile/library/common/BUILD | 2 -- mobile/library/common/internal_engine.cc | 2 -- 2 files changed, 4 deletions(-) diff --git a/mobile/library/common/BUILD b/mobile/library/common/BUILD index 5df532fc8b8a..bca2df8d0a2f 100644 --- a/mobile/library/common/BUILD +++ b/mobile/library/common/BUILD @@ -37,9 +37,7 @@ envoy_cc_library( "//library/common/types:c_types_lib", "@envoy//envoy/server:lifecycle_notifier_interface", "@envoy//envoy/stats:stats_interface", - "@envoy//source/common/common:minimal_logger_lib", "@envoy//source/common/common:thread_impl_lib_posix", - "@envoy//source/common/common:thread_lib", "@envoy//source/common/common:utility_lib", "@envoy//source/common/runtime:runtime_lib", "@envoy_build_config//:extension_registry", diff --git a/mobile/library/common/internal_engine.cc b/mobile/library/common/internal_engine.cc index 3aa97cb9eefb..24b547efe1d0 100644 --- a/mobile/library/common/internal_engine.cc +++ b/mobile/library/common/internal_engine.cc @@ -4,8 +4,6 @@ #include "source/common/api/os_sys_calls_impl.h" #include "source/common/common/lock_guard.h" -#include "source/common/common/logger.h" -#include "source/common/common/thread.h" #include "source/common/common/utility.h" #include "source/common/http/http_server_properties_cache_manager_impl.h" #include "source/common/network/io_socket_handle_impl.h" From 29f75fd341b36a39409298cb44ae0d6571458a58 Mon Sep 17 00:00:00 2001 From: Ali Beyad Date: Mon, 3 Feb 2025 20:35:02 +0000 Subject: [PATCH 9/9] fix test Signed-off-by: Ali Beyad --- mobile/test/common/integration/client_integration_test.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/mobile/test/common/integration/client_integration_test.cc b/mobile/test/common/integration/client_integration_test.cc index 433ba7f8062b..c103cb75409c 100644 --- a/mobile/test/common/integration/client_integration_test.cc +++ b/mobile/test/common/integration/client_integration_test.cc @@ -78,6 +78,7 @@ class ClientIntegrationTest } void initialize() override { + builder_.setLogLevel(Logger::Logger::debug); builder_.addRuntimeGuard("dns_cache_set_ip_version_to_remove", true); builder_.addRuntimeGuard("quic_no_tcp_delay", true);