Skip to content

Draft: tor-chanmgr: revert `PendingChannelHandle` drop behaviour, and try to prevent problematic code paths

opara requested to merge opara/arti:orport into main

In !2538 (merged) PendingChannelHandle was introduced, which would automatically remove the pending channel from the channel map when dropped. But it could lead to accidental deadlocks in the future if code in crates/tor-chanmgr/src/mgr/state.rs were modified and dropped the handle while already holding MgrStates internal lock.

This MR keeps the PendingChannelHandle but reverts the "remove from map on drop" behaviour. This means that its up to the calling code to make sure there are never code paths which lead to dropping PendingChannelHandle without passing it back to the MgrState through remove_pending_channel or replace_pending_channel. To help prevent this, dropping a PendingChannelHandle will now cause an error-level log message, and will panic in debug builds. This way hopefully we'll catch the issue in CI, or if a user sees the error message hopefully they'll report it so that we can fix it.

Merge request reports

Loading