Skip to content

Commit

Permalink
fix WRR race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
markdroth committed Aug 17, 2023
1 parent 33082ba commit 8a746ad
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,9 @@ void WeightedRoundRobin::Picker::BuildSchedulerAndStartTimerLocked() {
// Start timer.
WeakRefCountedPtr<Picker> self = WeakRef();
timer_handle_ = wrr_->channel_control_helper()->GetEventEngine()->RunAfter(
config_->weight_update_period(), [self = std::move(self)]() mutable {
config_->weight_update_period(),
[self = std::move(self), work_serializer = wrr_->work_serializer()]()
mutable {
ApplicationCallbackExecCtx callback_exec_ctx;
ExecCtx exec_ctx;
{
Expand All @@ -617,9 +619,7 @@ void WeightedRoundRobin::Picker::BuildSchedulerAndStartTimerLocked() {
}
}
// Release the picker ref inside the WorkSerializer.
auto* self_ptr = self.get();
self_ptr->wrr_->work_serializer()->Run([self = std::move(self)]() {},
DEBUG_LOCATION);
work_serializer->Run([self = std::move(self)]() {}, DEBUG_LOCATION);
});
}

Expand Down

0 comments on commit 8a746ad

Please sign in to comment.