Skip to content

Commit

Permalink
Check if the client is still connected
Browse files Browse the repository at this point in the history
Signed-off-by: Tao He <[email protected]>
  • Loading branch information
sighingnow committed Aug 30, 2023
1 parent c2d36ad commit ca68028
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion rust/vineyard/src/client/ipc_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,9 @@ impl IPCClientManager {
let mut clients = IPCClientManager::get_clients().lock()?;
let socket = socket.into();
if let Some(client) = clients.get(&socket) {
return Ok(client.clone());
if client.lock()?.connected() {
return Ok(client.clone());
}
}
let client = Arc::new(Mutex::new(IPCClient::connect(&socket)?));
clients.insert(socket, client.clone());
Expand Down
4 changes: 3 additions & 1 deletion rust/vineyard/src/client/rpc_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ impl RPCClientManager {
let mut clients: std::sync::MutexGuard<'_, _> = RPCClientManager::get_clients().lock()?;
let endpoint: String = endpoint.into();
if let Some(client) = clients.get(endpoint.as_str()) {
return Ok(client.clone());
if client.lock()?.connected() {
return Ok(client.clone());
}
}
let client = Arc::new(Mutex::new(RPCClient::connect_with_endpoint(&endpoint)?));
clients.insert(endpoint, client.clone());
Expand Down

0 comments on commit ca68028

Please sign in to comment.