chenBright commented on code in PR #1817:
URL: https://github.com/apache/incubator-brpc/pull/1817#discussion_r928101095
##########
src/brpc/socket.h:
##########
@@ -784,9 +785,17 @@ friend void DereferenceSocket(Socket*);
// Set by SetLogOff
butil::atomic<bool> _logoff_flag;
- // Flag used to mark whether additional reference has been decreased
- // by either `SetFailed' or `SetRecycle'
- butil::atomic<bool> _recycle_flag;
+ enum AdditionalRefStatus {
+ REF_USING, // additional ref is using normally
+ REF_REVIVING, // additional ref is reviving
+ REF_RECYLED // additional ref has benn recyled
Review Comment:
> 一个Nice To Have:这里会有2次HC,第一次HC是真正的HC,第二次HC是因为这个极端case导致的false
positive(其实对端server已经恢复了),理论上只做一次HC即可。
>
> 可以不用在这个PR实现,有兴趣的话可以想想怎么解决 :)
设个标志_is_hc_started(`atomic<bool>`),默认为false。[hc开始的时候](https://github.com/apache/incubator-brpc/blob/master/src/brpc/socket.cpp#L850)判断_is_hc_started.compare_exchange_strong(expect,
true,butil::memory_order_relaxed),其中expect为false。如果为true,则表示无hc,可以进行hc;否则,跳过,不进行hc。当hc结束时,将_is_hc_started置为false。这样应该可以避免同时进行2次hc的问题。
--
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]