Skip to content

Commit

Permalink
Merge pull request #3197 from TheBlueMatt/2024-07-stupid-locked-connect
Browse files Browse the repository at this point in the history
[block-sync] Don't hold client-cache lock while connecting
  • Loading branch information
TheBlueMatt authored Jul 22, 2024
2 parents 3733103 + 7945af7 commit 2b1d6aa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lightning-block-sync/src/rest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ impl RestClient {
{
let host = format!("{}:{}", self.endpoint.host(), self.endpoint.port());
let uri = format!("{}/{}", self.endpoint.path().trim_end_matches("/"), resource_path);
let mut client = if let Some(client) = self.client.lock().unwrap().take() {
let reserved_client = self.client.lock().unwrap().take();
let mut client = if let Some(client) = reserved_client {
client
} else {
HttpClient::connect(&self.endpoint)?
Expand Down
3 changes: 2 additions & 1 deletion lightning-block-sync/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ impl RpcClient {
"id": &self.id.fetch_add(1, Ordering::AcqRel).to_string()
});

let mut client = if let Some(client) = self.client.lock().unwrap().take() {
let reserved_client = self.client.lock().unwrap().take();
let mut client = if let Some(client) = reserved_client {
client
} else {
HttpClient::connect(&self.endpoint)?
Expand Down

0 comments on commit 2b1d6aa

Please sign in to comment.