Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

bug: prevent interleaving websocket ID load/store operations #217

Merged
merged 1 commit into from
Mar 2, 2021

Conversation

prestwich
Copy link
Collaborator

Closes #216.

The independent load and store operations could be interleaved between tasks in a breaking way.

e.g.

TASK A loads 5
TASK B loads 5
TASK B stores 6 (5 + 1)
TASK A stores 6 (5 + 1)

This causes both task A and task B to use the same ID for a WS request, replacing the previous request.

To fix this, we use fetch_add to atomically load, increment, and store

@prestwich prestwich requested a review from gakonst March 2, 2021 22:01
@gakonst gakonst merged commit 79e806f into master Mar 2, 2021
@gakonst gakonst deleted the prestwich/fetch-add branch March 2, 2021 22:19
@gakonst gakonst mentioned this pull request Mar 3, 2021
@prestwich prestwich mentioned this pull request Nov 17, 2021
3 tasks
meetmangukiya pushed a commit to meetmangukiya/ethers-rs that referenced this pull request Mar 21, 2022
* more stable build args detection

* chore: fmt / lints

Co-authored-by: Georgios Konstantopoulos <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Race condition using WebSockets
2 participants