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

Commit

Permalink
fix:Double locking
Browse files Browse the repository at this point in the history
  • Loading branch information
Leander Beernaert committed Nov 17, 2023
1 parent 7c8ff20 commit 4597810
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/clientv2/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,21 +264,20 @@ fn wrap_session_request<'a, R: RequestDesc + 'a>(
if let http::Error::API(api_err) = &e {
if api_err.http_code == 401 {
log::debug!("Account session expired, attempting refresh");
let borrow = session.user_auth.read();
return Ok(AuthRefreshRequest::new(
borrow.uid.expose_secret(),
borrow.refresh_token.expose_secret(),
)
.to_request()
return Ok({
let borrow = session.user_auth.read();
AuthRefreshRequest::new(
borrow.uid.expose_secret(),
borrow.refresh_token.expose_secret(),
)
.to_request()
}
.chain(move |resp| {
{
let data = {
let mut writer = session.user_auth.write();
*writer = UserAuth::from_auth_refresh_response(resp);
}
let data = {
let borrow = session.user_auth.read();
data.header(X_PM_UID_HEADER, borrow.uid.expose_secret().as_str())
.bearer_token(borrow.access_token.expose_secret())
data.header(X_PM_UID_HEADER, writer.uid.expose_secret().as_str())
.bearer_token(writer.access_token.expose_secret())
};
Ok(OwnedRequest::<R::Response>::new(data))
}));
Expand Down

0 comments on commit 4597810

Please sign in to comment.