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:
Conner Fromknecht 2017-08-08 16:51:41 -07:00 committed by Olaoluwa Osuntokun
parent 80a8cc0add
commit 91d6b0492e
1 changed files with 327 additions and 385 deletions

712
server.go

File diff suppressed because it is too large Load Diff