registry exit: decrement local span ref only #3331
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Fixes #3223
Solution
From my understanding, it's sufficient for
Registry::exit
just to callself.try_close()
and do local bookkeeping:try_close
on the wholeLayer
stack at this point anyway, a span being exited is not yet ready to close. All that is needed is to decrement the reference count within the current registry.I've added a test which spawns a thread and enters (and exits, and drops) a span created on a dispatcher not registered to that thread.
Before this patch, the test fails with the span never being closed (because there is no thread dispatcher when the span is exited, and so a reference is leaked in
Registry::exit
).With this patch, the bookkeeping demonstrated in the test seems correct to me.