This is an automated email from the ASF dual-hosted git repository. wwbmmm pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/brpc.git
The following commit(s) were added to refs/heads/master by this push: new 713bbb17 lalb try left server nodes (#2428) 713bbb17 is described below commit 713bbb175811f1919737fb22f221938f4c7b12eb Author: Yazawa Nico <37871611+fancy...@users.noreply.github.com> AuthorDate: Mon Nov 27 17:19:14 2023 +0800 lalb try left server nodes (#2428) * lalb try left server nodes * beautify * add comment * typo --------- Co-authored-by: zhoushan <zhous...@pinduoduo.com> --- src/brpc/policy/locality_aware_load_balancer.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/brpc/policy/locality_aware_load_balancer.cpp b/src/brpc/policy/locality_aware_load_balancer.cpp index 6f0c163c..68d85ad3 100644 --- a/src/brpc/policy/locality_aware_load_balancer.cpp +++ b/src/brpc/policy/locality_aware_load_balancer.cpp @@ -334,9 +334,13 @@ int LocalityAwareLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) if (dice >= left + self + diff) { dice -= left + self + diff; index = index * 2 + 2; - if (index < n) { - continue; - } + } else { + // left child may contain available nodes + dice = butil::fast_rand_less_than(left); + index = index * 2 + 1; + } + if (index < n) { + continue; } if (++ntry >= n) { break; --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org For additional commands, e-mail: dev-h...@brpc.apache.org