Modifications to the greylist (appending or deleting from) are dangerous while the refinery is ongoing, since it can lead to panics in the case the refinery fails (because we delete from the greylist by index when that happens).
We mitigate this issue by acquiring an exclusive lock on the greylist before proceeding with the refinery, and dropping the lock once the refinery process has finished and greylist modifications are no longer dangerous.
Modifications to the greylist (appending or deleting from) are dangerous while the refinery is ongoing, since it can lead to panics in the case the refinery fails (because we delete from the greylist by index when that happens).
We mitigate this issue by acquiring an exclusive lock on the greylist before proceeding with the refinery, and dropping the lock once the refinery process has finished and greylist modifications are no longer dangerous.
* Move greylist refinery and ping self process into Session.
* Remove hosts/ submodule and return store to net/hosts.rs
* Temporarily disable Gold/ Grey list upgrade and downgrade (we will move into RefineSession)
this leads to cleaner code since depending on the use case we still do
different things with the HostState following move_host(). However it
does mean that unregister() has to be called manually in some cases.
Previously there was a bug which happened v rarely in which:
> Outbound and Manual Session are waiting on a stop signal
> Outbound/ Manual receives a stop signal, de-registers channel (in move_host)
> Channel is selected by Slot 1 to be connected to, state is changed to Connect
> remove_sub_on_stop() receives a stop signal, de-registers channel
> Channel is selected by Slot 5 connected to, state is changed to Connect
> Slot 1 connects, state is changed to Connected
> Slot 5 connects -> panic!
To avoid this happening, we move unregister() out of move_host and perform the sequence:
recv stop signal -> move_host to greylist (if outbond/manual) -> unregister()
We do this inside the shared method remove_sub_on_stop to ensure the execution path always happens in the same way.