fix: refuse to clobber active socket
This commit is contained in:
parent
3288f18d85
commit
cd53858190
@ -47,6 +47,16 @@ async fn create_provider_socket(name: &'static str, socket: &'static str) -> Res
|
||||
let mut sock_path = get_run_path()?;
|
||||
sock_path.push(format!("{}.sock", socket));
|
||||
if smol::fs::metadata(&sock_path).await.is_ok() {
|
||||
for entry in smol::fs::read_to_string("/proc/net/unix").await?.lines() {
|
||||
if entry.contains(socket) {
|
||||
tracing::error!(
|
||||
"Another instance is already using the {} socket {}!",
|
||||
name,
|
||||
socket
|
||||
);
|
||||
return Err(anyhow!("Socket in use"));
|
||||
}
|
||||
}
|
||||
tracing::debug!("removing old {} socket", name);
|
||||
smol::fs::remove_file(&sock_path).await?;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user