Dropping DefaultGuard
s in wrong order can leave wrong dispatch active
#1657
Labels
DefaultGuard
s in wrong order can leave wrong dispatch active
#1657
Bug Report
Version
Platform
Darwin DeerBook 20.6.0 Darwin Kernel Version 20.6.0: Mon Aug 30 06:12:21 PDT 2021; root:xnu-7195.141.6~3/RELEASE_X86_64 x86_64
Crates
tracing-core
Description
Dropping
DefaultGuard
s in a different order than they were created will leave the wrong dispatch active. If I make twoset_default
calls and drop their guards in the opposite order, the dispatch/subscriber given to the firstset_default
call will remain active after both guards have been dropped.Reproduction
Proposal
The default dispatch should be treated as a stack, where each
DefaultGuard
removes its associated dispatch from the stack. If it was not the topmost dispatch, the current default won't change, and removing the second dispatch before the topmost dispatch will properly restore the third dispatch upon removing the topmost.One way to implement this is to make the default dispatch into a doubly-linked list, such that the guard holds a reference to the node it inserts. This way each guard can easily remove its corresponding node from the list.
The text was updated successfully, but these errors were encountered: