First deregister, then lock. This is important to avoid deadlocks
between unregistering connections.
Don't readlock connections when they're about to be shut down.
Read-lock the wrapper connection rather than the wrapped one when
setting up.
When taking the connection list lock for determining if the connection
is eligible, we don't actually need to write-lock the list as it isn't
actually modified.