Skip to content

Gateway concurrency

David Vorick requested to merge gateway-concurrency into master

This pull request is most easily digested going commit-to-commit. They are pretty cleanly separated.

I went through and fixed up a lot of the concurrency patterns in the gateway. None of the changes have proper tests, but all of the old tests are still passing. Several deadlocks have been removed, and the biggest offenders in terms of quick-shutdown have been removed.

Some things remain on my todo list:

  1. threadedListenPeer is not fixed up yet, it violates the 'don't hold a tg.Add() for long periods of time` rule, and has some other weirdness to the concurrency that I don't like.
  2. managedConnectNewPeer, managedConnectOldPeer, managedAcceptConnectNewPeer, and managedAcceptConnectOldPeer all don't support quick-shutdown. I may have slipped in a goroutine here or there that is not being correctly closed with regards to these functions, can clean that up tomorrow.
  3. threadedHandleConn does not yet support clean shutdown.

I am considering abandoning the pursuit of clean shutdown for the code that does not have it yet. The biggest offenders have already been addressed. That would just leave threadedListenPeer on my todo list.

Oh, and testing, as a lot of this code is not tested well, even though the whole test suite is passing.

Merge request reports