Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions include/envoy/init/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,23 @@ load(
envoy_package()

envoy_cc_library(
name = "init_interface",
hdrs = ["init.h"],
name = "watcher_interface",
hdrs = ["watcher.h"],
)

envoy_cc_library(
name = "target_interface",
hdrs = ["target.h"],
deps = [
":watcher_interface",
],
)

envoy_cc_library(
name = "manager_interface",
hdrs = ["manager.h"],
deps = [
":target_interface",
":watcher_interface",
],
)
66 changes: 0 additions & 66 deletions include/envoy/init/init.h

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#pragma once

#include "envoy/common/pure.h"
#include "envoy/safe_init/target.h"
#include "envoy/safe_init/watcher.h"
#include "envoy/init/target.h"
#include "envoy/init/watcher.h"

namespace Envoy {
namespace SafeInit {
namespace Init {

/**
* SafeInit::Manager coordinates initialization of one or more "targets." A typical flow would be:
* Init::Manager coordinates initialization of one or more "targets." A typical flow would be:
*
* - One or more initialization targets are registered with a manager using `add`.
* - The manager is told to `initialize` all its targets, given a Watcher to notify when all
Expand All @@ -21,14 +21,14 @@ namespace SafeInit {
* Since there are several entities involved in this flow -- the owner of the manager, the targets
* registered with the manager, and the manager itself -- it may be difficult or impossible in some
* cases to guarantee that their lifetimes line up correctly to avoid use-after-free errors. The
* interface design here in SafeInit allows implementations to avoid the issue:
* interface design here in Init allows implementations to avoid the issue:
*
* - A Target can only be initialized via a TargetHandle, which acts as a weak reference.
* Attempting to initialize a destroyed Target via its handle has no ill effects.
* - Likewise, a Watcher can only be notified that initialization was complete via a
* WatcherHandle, which acts as a weak reference as well.
*
* See target.h and watcher.h, as well as implementation in source/common/safe_init for details.
* See target.h and watcher.h, as well as implementation in source/common/init for details.
*/
struct Manager {
virtual ~Manager() = default;
Expand Down Expand Up @@ -75,5 +75,5 @@ struct Manager {
virtual void initialize(const Watcher& watcher) PURE;
};

} // namespace SafeInit
} // namespace Init
} // namespace Envoy
10 changes: 5 additions & 5 deletions include/envoy/safe_init/target.h → include/envoy/init/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
#include <memory>

#include "envoy/common/pure.h"
#include "envoy/safe_init/watcher.h"
#include "envoy/init/watcher.h"

#include "absl/strings/string_view.h"

namespace Envoy {
namespace SafeInit {
namespace Init {

/**
* A TargetHandle functions as a weak reference to a Target. It is how an implementation of
* SafeInit::Manager would safely tell a target to `initialize` with no guarantees about the
* target's lifetime. Typical usage (outside of SafeInit::ManagerImpl) does not require touching
* Init::Manager would safely tell a target to `initialize` with no guarantees about the
* target's lifetime. Typical usage (outside of Init::ManagerImpl) does not require touching
* TargetHandles at all.
*/
struct TargetHandle {
Expand Down Expand Up @@ -48,5 +48,5 @@ struct Target {
virtual TargetHandlePtr createHandle(absl::string_view name) const PURE;
};

} // namespace SafeInit
} // namespace Init
} // namespace Envoy
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
#include "absl/strings/string_view.h"

namespace Envoy {
namespace SafeInit {
namespace Init {

/**
* A WatcherHandle functions as a weak reference to a Watcher. It is how an implementation of
* SafeInit::Target would safely notify a Manager that it has initialized, and likewise it's how
* an implementation of SafeInit::Manager would safely tell its client that all registered targets
* Init::Target would safely notify a Manager that it has initialized, and likewise it's how
* an implementation of Init::Manager would safely tell its client that all registered targets
* have initialized, with no guarantees about the lifetimes of the manager or client. Typical usage
* (outside of SafeInit::TargetImpl and ManagerImpl) does not require touching WatcherHandles at
* (outside of Init::TargetImpl and ManagerImpl) does not require touching WatcherHandles at
* all.
*/
struct WatcherHandle {
Expand Down Expand Up @@ -49,5 +49,5 @@ struct Watcher {
virtual WatcherHandlePtr createHandle(absl::string_view name) const PURE;
};

} // namespace SafeInit
} // namespace Init
} // namespace Envoy
1 change: 0 additions & 1 deletion include/envoy/router/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ envoy_cc_library(
deps = [
":rds_interface",
"//include/envoy/event:dispatcher_interface",
"//include/envoy/init:init_interface",
"//include/envoy/json:json_object_interface",
"//include/envoy/local_info:local_info_interface",
"//include/envoy/runtime:runtime_interface",
Expand Down
1 change: 0 additions & 1 deletion include/envoy/router/route_config_provider_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#include "envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.pb.h"
#include "envoy/event/dispatcher.h"
#include "envoy/init/init.h"
#include "envoy/json/json_object.h"
#include "envoy/local_info/local_info.h"
#include "envoy/router/rds.h"
Expand Down
31 changes: 0 additions & 31 deletions include/envoy/safe_init/BUILD

This file was deleted.

6 changes: 3 additions & 3 deletions include/envoy/server/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ envoy_cc_library(
"//include/envoy/event:timer_interface",
"//include/envoy/http:context_interface",
"//include/envoy/http:query_params_interface",
"//include/envoy/init:init_interface",
"//include/envoy/init:manager_interface",
"//include/envoy/local_info:local_info_interface",
"//include/envoy/runtime:runtime_interface",
"//include/envoy/secret:secret_manager_interface",
Expand Down Expand Up @@ -151,7 +151,7 @@ envoy_cc_library(
"//include/envoy/http:codes_interface",
"//include/envoy/http:context_interface",
"//include/envoy/http:filter_interface",
"//include/envoy/init:init_interface",
"//include/envoy/init:manager_interface",
"//include/envoy/json:json_object_interface",
"//include/envoy/local_info:local_info_interface",
"//include/envoy/network:drain_decision_interface",
Expand Down Expand Up @@ -196,7 +196,7 @@ envoy_cc_library(
hdrs = ["transport_socket_config.h"],
deps = [
"//include/envoy/event:dispatcher_interface",
"//include/envoy/init:init_interface",
"//include/envoy/init:manager_interface",
"//include/envoy/local_info:local_info_interface",
"//include/envoy/network:transport_socket_interface",
"//include/envoy/runtime:runtime_interface",
Expand Down
2 changes: 1 addition & 1 deletion include/envoy/server/filter_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "envoy/http/codes.h"
#include "envoy/http/context.h"
#include "envoy/http/filter.h"
#include "envoy/init/init.h"
#include "envoy/init/manager.h"
#include "envoy/json/json_object.h"
#include "envoy/network/drain_decision.h"
#include "envoy/network/filter.h"
Expand Down
2 changes: 1 addition & 1 deletion include/envoy/server/instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "envoy/common/mutex_tracer.h"
#include "envoy/event/timer.h"
#include "envoy/http/context.h"
#include "envoy/init/init.h"
#include "envoy/init/manager.h"
#include "envoy/local_info/local_info.h"
#include "envoy/network/listen_socket.h"
#include "envoy/runtime/runtime.h"
Expand Down
2 changes: 1 addition & 1 deletion include/envoy/server/transport_socket_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <string>

#include "envoy/event/dispatcher.h"
#include "envoy/init/init.h"
#include "envoy/init/manager.h"
#include "envoy/local_info/local_info.h"
#include "envoy/network/transport_socket.h"
#include "envoy/runtime/runtime.h"
Expand Down
3 changes: 2 additions & 1 deletion source/common/config/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -391,11 +391,12 @@ envoy_cc_library(
":utility_lib",
"//include/envoy/config:config_provider_interface",
"//include/envoy/config:config_provider_manager_interface",
"//include/envoy/init:init_interface",
"//include/envoy/init:manager_interface",
"//include/envoy/server:admin_interface",
"//include/envoy/server:config_tracker_interface",
"//include/envoy/singleton:instance_interface",
"//include/envoy/thread_local:thread_local_interface",
"//source/common/init:target_lib",
"//source/common/protobuf",
],
)
9 changes: 1 addition & 8 deletions source/common/config/config_provider_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,10 @@ ImmutableConfigProviderImplBase::~ImmutableConfigProviderImplBase() {
}

ConfigSubscriptionInstanceBase::~ConfigSubscriptionInstanceBase() {
runInitializeCallbackIfAny();
init_target_.ready();
config_provider_manager_.unbindSubscription(manager_identifier_);
}

void ConfigSubscriptionInstanceBase::runInitializeCallbackIfAny() {
if (initialize_callback_) {
initialize_callback_();
initialize_callback_ = nullptr;
}
}

bool ConfigSubscriptionInstanceBase::checkAndApplyConfig(const Protobuf::Message& config_proto,
const std::string& config_name,
const std::string& version_info) {
Expand Down
Loading