mirror of https://github.com/grpc/grpc.git
[chaotic good] fix bugs causing thready_tsan failures in handshaking (#37049)
There were two problems here:
1. A pre-existing bug in the chaotic good connector whereby it was using `std::shared_ptr<>` instead of `RefCountedPtr<>` for `HandshakeManager`, thus failing to account for the internal refs taken inside `HandshakeManager` before deciding to delete the object.
2. A change made as part of #37018 made `HandshakeManager` less tolerant to a caller that unrefs the `HandshakeManager` in the `on_handshake_done` callback, which may be run in another thread while the first thread is still holding the mutex in `HandshakeManager::DoHandshake()`. To be defensive for this case, `DoHandshake()` now holds its own ref, which it releases after releasing the mutex.
The second problem is in principle not specific to chaotic good, but in practice it almost certainly is, because the chttp2 connector does a bunch of other work (e.g., starting another timer for the settings timeout) before unreffing the `HandshakeManager`, so it would not trigger this race condition.
Closes #37049
COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/37049 from markdroth:chaotic_good_connector_thready_tsan_fix 6821dd1418
PiperOrigin-RevId: 646628702
pull/37062/head
parent
9bad573c05
commit
6d2ba78bc0
3 changed files with 7 additions and 2 deletions
Loading…
Reference in new issue