Skip to content
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

Fix: transactional pause #254

Merged
merged 3 commits into from
Oct 12, 2024
Merged

Conversation

Mrreadiness
Copy link
Contributor

Hi! Thanks for the great library!
I've recently faced a bug when pausing while initializing torrent returned an error, but it changed the internal flag. This fix should prevent such behavior.

@@ -1365,8 +1365,20 @@ impl Session {
}

pub async fn pause(&self, handle: &ManagedTorrentHandle) -> anyhow::Result<()> {
handle.locked.write().paused = true;
handle.pause()?;
let prev_state;
Copy link
Owner

Choose a reason for hiding this comment

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

Can it be simplified by first calling handle.pause(), and then only if it was successful set paused = true?

This way the lock is taken only once

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it makes sense. Updated.

@ikatson ikatson merged commit 946ad36 into ikatson:main Oct 12, 2024
6 checks passed
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.

2 participants