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(iroh): do not double-close docs on drop #2383

Merged
merged 2 commits into from
Jun 20, 2024
Merged

Conversation

Frando
Copy link
Member

@Frando Frando commented Jun 18, 2024

Description

We unconditionally sent a DocClose RPC message when dropping a iroh::client::docs::Doc struct. However, we should only ever send a DocClose once for each doc instance, because otherwise the reference counter in the backend will decrease twice, and thus closing the resource in the backend too soon, affecting other open client instances. This was either an oversight or got lost in refactorings, not sure anymore. In any case: This PR fixes the behavior, and also adds a test that fails without this fix.

Fixes #2381

Breaking Changes

Notes & open questions

Change checklist

  • Self-review.
  • Documentation updates if relevant.
  • Tests if relevant.
  • All breaking changes documented.

@Frando Frando changed the title fix(iroh): do not double-close docs when dropping fix(iroh): do not double-close docs on drop Jun 18, 2024
@Frando Frando marked this pull request as ready for review June 18, 2024 22:26
@divagant-martian divagant-martian added this pull request to the merge queue Jun 19, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jun 19, 2024
@Frando Frando added this pull request to the merge queue Jun 20, 2024
Merged via the queue into main with commit 55a0c0b Jun 20, 2024
25 checks passed
@dignifiedquire dignifiedquire deleted the fix/docs-client-close branch June 20, 2024 09:40
ppodolsky pushed a commit to izihawa/iroh that referenced this pull request Jun 22, 2024
## Description

We unconditionally sent a `DocClose` RPC message when dropping a
`iroh::client::docs::Doc` struct. However, we should only ever send a
`DocClose` *once* for each doc instance, because otherwise the reference
counter in the backend will decrease *twice*, and thus closing the
resource in the backend too soon, affecting other open client instances.
This was either an oversight or got lost in refactorings, not sure
anymore. In any case: This PR fixes the behavior, and also adds a test
that fails without this fix.

Fixes n0-computer#2381 

## Breaking Changes

<!-- Optional, if there are any breaking changes document them,
including how to migrate older code. -->

## Notes & open questions

<!-- Any notes, remarks or open questions you have to make about the PR.
-->

## Change checklist

- [x] Self-review.
- [ ] ~~Documentation updates if relevant.~~
- [x] Tests if relevant.
- [x] All breaking changes documented.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Dropping a Doc Handle Closes the Connection on Other Doc Handles That Have Been Independently Opened
2 participants