hjwsm1989 commented on code in PR #3359:
URL: https://github.com/apache/brpc/pull/3359#discussion_r3485802491
##########
src/brpc/selective_channel.cpp:
##########
@@ -306,14 +306,20 @@ Sender::Sender(Controller* cntl,
int Sender::IssueRPC(int64_t start_realtime_us) {
_main_cntl->_current_call.need_feedback = false;
+ ChannelBalancer* balancer =
+ static_cast<ChannelBalancer*>(_main_cntl->_lb.get());
+ if (balancer == NULL) {
+ _main_cntl->SetFailed(ECANCELED,
+ "SelectiveChannel balancer is unavailable");
+ return -1;
+ }
Review Comment:
@chenBright thanks for review, The previous null check was not enough
because it did not keep the balancer alive after `_lb.get()`.
I updated the patch so `Sender` holds its own
`intrusive_ptr<SharedLoadBalancer>` captured from `SelectiveChannel` at
creation time, and `IssueRPC()` uses that retained reference. This prevents
`main_cntl->_lb.reset()` in `EndRPC()` from freeing the balancer while
`IssueRPC()` is still using it.
The `FLAGS_ENDING_RPC` guard is kept to prevent late `SubDone` from
re-entering retry / backup after the main RPC starts ending.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]