Skip to content
Closed
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
8 changes: 8 additions & 0 deletions source/common/config/grpc_mux_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ GrpcMuxImpl::~GrpcMuxImpl() {
}
}

void GrpcMuxImpl::disableSendUpdateAtWatcherDelete() {
for (const auto& api_state : api_state_) {
for (auto watch : api_state.second.watches_) {
watch->send_update_at_delete_ = false;
}
}
}

void GrpcMuxImpl::start() { establishNewStream(); }

void GrpcMuxImpl::setRetryTimer() {
Expand Down
8 changes: 6 additions & 2 deletions source/common/config/grpc_mux_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class GrpcMuxImpl : public GrpcMux,
Runtime::RandomGenerator& random);
~GrpcMuxImpl();

// Not to send any update requests when watchers are removed.
void disableSendUpdateAtWatcherDelete();

void start() override;
GrpcMuxWatchPtr subscribe(const std::string& type_url, const std::vector<std::string>& resources,
GrpcMuxCallbacks& callbacks) override;
Expand Down Expand Up @@ -56,14 +59,14 @@ class GrpcMuxImpl : public GrpcMux,
GrpcMuxWatchImpl(const std::vector<std::string>& resources, GrpcMuxCallbacks& callbacks,
const std::string& type_url, GrpcMuxImpl& parent)
: resources_(resources), callbacks_(callbacks), type_url_(type_url), parent_(parent),
inserted_(true) {
inserted_(true), send_update_at_delete_(true) {
entry_ = parent.api_state_[type_url].watches_.emplace(
parent.api_state_[type_url].watches_.begin(), this);
}
~GrpcMuxWatchImpl() override {
if (inserted_) {
parent_.api_state_[type_url_].watches_.erase(entry_);
if (!resources_.empty()) {
if (send_update_at_delete_ && !resources_.empty()) {
parent_.sendDiscoveryRequest(type_url_);
}
}
Expand All @@ -74,6 +77,7 @@ class GrpcMuxImpl : public GrpcMux,
GrpcMuxImpl& parent_;
std::list<GrpcMuxWatchImpl*>::iterator entry_;
bool inserted_;
bool send_update_at_delete_;
};

// Per muxed API state.
Expand Down
1 change: 1 addition & 0 deletions source/common/config/grpc_subscription_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class GrpcSubscriptionImpl : public Config::Subscription<ResourceType> {
const Protobuf::MethodDescriptor& service_method, SubscriptionStats stats)
: grpc_mux_(local_info, std::move(async_client), dispatcher, service_method, random),
grpc_mux_subscription_(grpc_mux_, stats) {}
~GrpcSubscriptionImpl() { grpc_mux_.disableSendUpdateAtWatcherDelete(); }

// Config::Subscription
void start(const std::vector<std::string>& resources,
Expand Down
2 changes: 0 additions & 2 deletions test/common/config/grpc_subscription_test_harness.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ class GrpcSubscriptionTestHarness : public SubscriptionTestHarness {
*method_descriptor_, stats_));
}

~GrpcSubscriptionTestHarness() { EXPECT_CALL(async_stream_, sendMessage(_, false)); }

void expectSendMessage(const std::vector<std::string>& cluster_names,
const std::string& version) override {
expectSendMessage(cluster_names, version, Grpc::Status::GrpcStatus::Ok, "");
Expand Down