two-headBoy commented on code in PR #3595:
URL: https://github.com/apache/brpc/pull/3595#discussion_r4246989885
##########
src/brpc/selective_channel.cpp:
##########
@@ -197,19 +201,33 @@ int ChannelBalancer::AddChannel(ChannelBase* sub_channel,
options.health_check_interval_s = FLAGS_channel_check_interval;
if (Socket::Create(options, &sock_id) != 0) {
Review Comment:
Right —`get_resource()` returning before`OnCreated` means no callback runs,
so`sub_chan` (and`chan` under`OWNS_CHANNEL` ) would leak. Restored caller-owned
cleanup in`AddChannel` : when`Socket::Create` fails we now delete the
wrapper`sub_chan` ourselves, and`sub_channel` iff ownership is`OWNS_CHANNEL` .
This is sound because, per the socket change,`BeforeRecycle` never runs on any
create-failure path, so there is no double-free.`PartitionChannel` uses the
default`OWNS_CHANNEL` and relies on schan for cleanup (its redundant`delete
pchan` on failure was already removed), so it has a correct fallback via schan.
--
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]