mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 01:43:16 +01:00
server: refactors w/ single mutex and sync disconnect
This commit alters the synchronization patterns used in the server such that the internal state is protected by a single mutex. Overall, this simplifies the ability to reason about the behavior and manipulation of the internal state, which has resolved a few of flakes related to race conditions that were observed before hand. Invoking DisconnectPeer is now fully synchronous, and waits until the provided peer's peerTerminationWatcher has exited before returning. Currently this is done by tracking the watcher using the peer's WaitGroup, and locking until the peer has shutdown. The server's API has also been refactored such that all public methods are safe for concurrent use. Therefore, other subsystems should be sure to make use of these endpoints to avoid corrupting the internal state.
This commit is contained in:
parent
80a8cc0add
commit
91d6b0492e