Skip to content

Fix: transactional pause#254

Merged
ikatson merged 3 commits intoikatson:mainfrom
Mrreadiness:fix/transactional-pause
Oct 12, 2024
Merged

Fix: transactional pause#254
ikatson merged 3 commits intoikatson:mainfrom
Mrreadiness:fix/transactional-pause

Conversation

@Mrreadiness
Copy link
Copy Markdown
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.

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