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

Replace RwLock::try_read with RwLock::read in SyncStorage #2463

Merged
merged 1 commit into from
May 30, 2024

Conversation

ribelo
Copy link
Contributor

@ribelo ribelo commented May 30, 2024

Replace RwLock::try_read with RwLock::read in SyncStorage

This pull request replaces the use of RwLock::try_read with RwLock::read in the SyncStorage.

This change prioritizes potential deadlocks over panics. Unwrapping a failed try_read can lead to unexpected behavior and difficult-to-debug issues. Using RwLock::read ensures that the code will always block until a read lock is acquired, preventing potential panics but introducing the possibility of deadlocks.

This change is consistent with the current use of RwLock::write for write operations.

Changes:

  • Replaces RwLock::try_read with RwLock::read in SyncStorage.

Rationale:

  • Prioritizes potential deadlocks over panics.
  • Ensures consistent API with RwLock::write for write operations.

Potential Issues:

  • This change might introduce the possibility of deadlocks in scenarios where the read lock is consistently blocked, but all test passed.

Replaces `RwLock::try_read` with `RwLock::read` in `SyncStorage`. This change prioritizes potential deadlocks over panics, as unwrapping a failed `try_read` is deemed less desirable.
Copy link
Member

@ealmloff ealmloff left a comment

Choose a reason for hiding this comment

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

Yes, this is a bug. This was fixed for try_write a while back, but I forgot to update try_read. Thank you!

@ealmloff ealmloff merged commit 54dbe6d into DioxusLabs:main May 30, 2024
8 of 9 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