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

This commit is contained in:
James Prestwich 2021-03-02 14:19:20 -08:00 committed by GitHub
parent e7fa806f78
commit 79e806f6e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 2 deletions

View File

@ -112,8 +112,7 @@ impl JsonRpcClient for Ws {
method: &str,
params: T,
) -> Result<R, ClientError> {
let next_id = self.id.load(Ordering::SeqCst) + 1;
self.id.store(next_id, Ordering::SeqCst);
let next_id = self.id.fetch_add(1, Ordering::SeqCst);
// send the message
let (sender, receiver) = oneshot::channel();