Gmymymy commented on PR #3306:
URL: https://github.com/apache/brpc/pull/3306#issuecomment-4530942998
Thanks for the feedback. I agree that concurrent destroy+write is generally
the caller's responsibility.
However, I'd like to point out an inconsistency in the existing design:
`AgentCombiner` already uses `weak_ptr` in `Agent::~Agent()` to gracefully
handle the case where the combiner may be gone:
```cpp
~Agent() {
self_shared_type c = combiner.lock();
if (NULL != c) {
c->commit_and_erase(this);
}
}
```
This shows the design already anticipates lifetime overlap between agents
and their combiner. The `shared_from_this()` call in
`get_or_create_tls_agent()` is inconsistent with that approach — it crashes
instead of handling the expired case gracefully.
This fix makes the behavior consistent: both code paths now handle a gone
combiner without crashing.
--
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]