Skip to content

Commit

Permalink
refactor(rust): delay the unwrapping of the response of a secure request
Browse files Browse the repository at this point in the history
and stop the secure channel before unwrapping
  • Loading branch information
etorreborre committed Oct 2, 2023
1 parent f963080 commit 3ab0a09
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,13 @@ impl SecureClient {
let sc = self.create_secure_channel(ctx).await?;
let route = route![sc.clone(), api_service];
let client = Client::new(&route, Some(timeout));
let response = client.request(ctx, req).await?;
let response = client.request(ctx, req).await;
self.secure_channels
.stop_secure_channel(ctx, sc.encryptor_address())
.await?;
Ok(response)
// we delay the unwrapping of the response to make sure that the secure channel is
// properly stopped first
Ok(response?)
}

/// Create a secure channel to the node
Expand Down

0 comments on commit 3ab0a09

Please sign in to comment.