two-headBoy opened a new pull request, #3595:
URL: https://github.com/apache/brpc/pull/3595

   ### What problem does this PR solve?
   
   Issue Number: resolve #1408
   
   Problem Summary:
   
   - `SelectiveChannel::AddChannel` 各失败路径对用户 sub channel 的所有权处理不一致:有的泄漏(OWNS 
时未删用户 channel / 已创建的 fake Socket 未回收),有的行为不统一,调用方无法预判,容易泄漏或 double free。
   
   ### What is changed and the side effects?
   
   Changed:
   
   - 统一所有权语义为「OWNS_CHANNEL 一律接管、DOESNT_OWN_CHANNEL 一律不接管」,以首次成功注册为唯一事实源。
   - `Socket::Create` 失败时按 ownership 手动回收;其余失败路径对 fake Socket 调`SetFailed()` 
+`ReleaseHCRelatedReference()` ,由`SubChannel::BeforeRecycle` 按 ownership 清理;重复 
channel 返回 -1 且不改变任何东西。补充注释并新增单测。
   > 注:`Socket::Create` 失败、address 返回 < 0、健康检查未启用、`AddServer` 因`ServerId` 
重复失败等内部路径依赖 Socket 
内部状态,单测环境难以稳定复刻,正确性主要靠代码审查保证;单测覆盖外部可触发的失败(nullptr、重复)及成功路径,间接验证规则一致性。
   
   Side effects:
   
   - Performance effects: 无,仅修正失败路径回收,不影响成功热路径。
   - Breaking backward compatibility: 无破坏性变更,仅把失败路径从「可能泄漏」修正为「按 ownership 正确回收」。
   
   ---
   ### Check List:
   - Please make sure your changes are compilable.
   - When providing us with a new feature, it is best to add related tests.
   - Please follow [Contributor Covenant Code of 
Conduct](https://github.com/apache/brpc/blob/master/CODE_OF_CONDUCT.md).
   


-- 
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]

Reply via email to