Skip to content

fix: Explicitly drop SessionFlusher #326

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 26, 2021
Merged

fix: Explicitly drop SessionFlusher #326

merged 2 commits into from
Apr 26, 2021

Conversation

Swatinem
Copy link
Member

It seems that doing a thread::join from within the Drop impl of a thread
local THREAD_HUB will deadlock for some reason.
Explicitly joining the background flusher as part of the ClientGuard
Drop does work, and is also more correct, as otherwise the PROCESS_HUB
might keep the worker alive forever.

Fixes #322

It seems that doing a thread::join from within the Drop impl of a thread
local THREAD_HUB will deadlock for some reason.
Explicitly joining the background flusher as part of the ClientGuard
Drop does work, and is also more correct, as otherwise the PROCESS_HUB
might keep the worker alive forever.
@Swatinem Swatinem requested a review from a team April 26, 2021 10:52
@@ -43,7 +43,7 @@ pub(crate) type TransportArc = Arc<RwLock<Option<Arc<dyn Transport>>>>;
pub struct Client {
options: ClientOptions,
transport: TransportArc,
session_flusher: SessionFlusher,
session_flusher: RwLock<Option<SessionFlusher>>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to somehow leave an implementation note that explains why this is an option? If I read this correctly it only is an option because it allows you to explicitly drop the SessionFlusher on close. So this rather different from the thing being actually optional as you'd expect from an option.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed. Although maybe it would be better to just make client a newtype around Option<ClientInner> or something.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that sounds even nicer, also more work though ;)

@Swatinem Swatinem merged commit 0414b84 into master Apr 26, 2021
@Swatinem Swatinem deleted the fix/drop-flusher branch April 26, 2021 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test execution hangs if guards are used in multiple tests
2 participants