Skip to content

Verify that we only use 1 handle at a time in each function #21

@Lyrenhex

Description

@Lyrenhex

After verifying with the Tokio docs, RwLock is write-preferring, which can lead to a deadlock if the following occurs:

  1. We currently hold a read handle to a global state in Function A.
  2. An event is triggered which causes Function B to fire, which requests a write handle (enters waiting state).
  3. Function A calls another function which, in turn, also requests another read handle.

The second read handle in this example will never be granted, as it is waiting until Function B's write handle is granted. This, in turn, means Function A never finishes (and probably doesn't drop its read handle as a result), hence causing deadlock.

Need to do a pass over the code to ensure every function only ever holds a single handle at a time (including any function calls), which should avoid this issue from occurring...

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions