Skip to content
This repository was archived by the owner on Jul 6, 2024. It is now read-only.

Commit 8de9edd

Browse files
committed
fix: Deadlock on auto-refresh
1 parent 72f2006 commit 8de9edd

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "proton-api-rs"
33
authors = ["Leander Beernaert <[email protected]>"]
4-
version = "0.10.0"
4+
version = "0.10.1"
55
edition = "2021"
66
license = "AGPL-3.0-only"
77
description = "Unofficial implemention of proton REST API in rust"

src/clientv2/request_repeater.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,14 @@ impl RequestRepeater {
4141
}
4242

4343
fn refresh_auth<C: ClientSync>(&self, client: &C) -> http::Result<()> {
44-
let borrow = self.user_auth.read();
44+
let mut borrow = self.user_auth.write();
4545
match AuthRefreshRequest::new(
4646
borrow.uid.expose_secret(),
4747
borrow.refresh_token.expose_secret(),
4848
)
4949
.execute_sync(client, &DefaultRequestFactory {})
5050
{
5151
Ok(s) => {
52-
let mut borrow = self.user_auth.write();
5352
*borrow = UserAuth::from_auth_refresh_response(&s);
5453
if let Some(cb) = &self.on_auth_refreshed {
5554
cb.on_auth_refreshed(&borrow.uid, &borrow.access_token);
@@ -62,7 +61,7 @@ impl RequestRepeater {
6261

6362
async fn refresh_auth_async<C: ClientAsync>(&self, client: &C) -> http::Result<()> {
6463
// Have to clone here due to async boundaries.
65-
let user_auth = self.user_auth.read().clone();
64+
let user_auth = { self.user_auth.read().clone() };
6665
match AuthRefreshRequest::new(
6766
user_auth.uid.expose_secret(),
6867
user_auth.refresh_token.expose_secret(),

0 commit comments

Comments
 (0)