Remove external watcher before sending notification to avoid race condition.

pull/20408/head
Mark D. Roth 5 years ago
parent dbad2db848
commit 92f7faff05
  1. 4
      src/core/ext/filters/client_channel/client_channel.cc

@ -1151,11 +1151,11 @@ void ChannelData::ExternalConnectivityWatcher::Notify(
MemoryOrder::RELAXED)) { MemoryOrder::RELAXED)) {
return; // Already done. return; // Already done.
} }
// Remove external watcher.
chand_->RemoveExternalConnectivityWatcher(on_complete_, /*cancel=*/false);
// Report new state to the user. // Report new state to the user.
*state_ = state; *state_ = state;
GRPC_CLOSURE_SCHED(on_complete_, GRPC_ERROR_NONE); GRPC_CLOSURE_SCHED(on_complete_, GRPC_ERROR_NONE);
// Remove external watcher.
chand_->RemoveExternalConnectivityWatcher(on_complete_, /*cancel=*/false);
// Hop back into the combiner to clean up. // Hop back into the combiner to clean up.
// Not needed in state SHUTDOWN, because the tracker will // Not needed in state SHUTDOWN, because the tracker will
// automatically remove all watchers in that case. // automatically remove all watchers in that case.

Loading…
Cancel
Save