PollingResolver: Honor cancel action in Timer callback (#31826)

* reset timer handle when cancel failed, meaning the timer callback has
already been scheduled

* review

* review
pull/31842/head
Yijie Ma 2 years ago committed by GitHub
parent b19604ea60
commit 89f3b1f293
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      src/core/ext/filters/client_channel/resolver/polling_resolver.cc

@ -88,8 +88,11 @@ void PollingResolver::RequestReresolutionLocked() {
} }
void PollingResolver::ResetBackoffLocked() { void PollingResolver::ResetBackoffLocked() {
MaybeCancelNextResolutionTimer();
backoff_.Reset(); backoff_.Reset();
if (next_resolution_timer_handle_.has_value()) {
MaybeCancelNextResolutionTimer();
StartResolvingLocked();
}
} }
void PollingResolver::ShutdownLocked() { void PollingResolver::ShutdownLocked() {
@ -121,8 +124,9 @@ void PollingResolver::OnNextResolutionLocked() {
"[polling resolver %p] re-resolution timer fired: shutdown_=%d", "[polling resolver %p] re-resolution timer fired: shutdown_=%d",
this, shutdown_); this, shutdown_);
} }
next_resolution_timer_handle_.reset(); // If we haven't been cancelled nor shutdown, then start resolving.
if (!shutdown_) { if (next_resolution_timer_handle_.has_value() && !shutdown_) {
next_resolution_timer_handle_.reset();
StartResolvingLocked(); StartResolvingLocked();
} }
} }

Loading…
Cancel
Save