From: David Mulder Date: Fri, 23 Aug 2024 20:07:08 +0000 (-0600) Subject: Remove the existing socket if present X-Git-Tag: tdb-1.4.13~881 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cb23d6a15e2028eb4116df153d7f13ba8918bd08;p=thirdparty%2Fsamba.git Remove the existing socket if present Signed-off-by: David Mulder Reviewed-by: Alexander Bokovoy --- diff --git a/rust/himmelblaud/src/main.rs b/rust/himmelblaud/src/main.rs index bc9f2f4f6a4..27672175be7 100644 --- a/rust/himmelblaud/src/main.rs +++ b/rust/himmelblaud/src/main.rs @@ -145,15 +145,21 @@ async fn main() -> ExitCode { } }; let sock_dir = Path::new(&sock_dir_str); - let mut sock_path = PathBuf::from(sock_dir); - sock_path.push("hb_pipe"); - let sock_path = match sock_path.to_str() { + let mut sock_path_buf = PathBuf::from(sock_dir); + sock_path_buf.push("hb_pipe"); + let sock_path = match sock_path_buf.to_str() { Some(sock_path) => sock_path, None => { talloc::TALLOC_FREE!(frame); return ExitCode::FAILURE; } }; + if sock_path_buf.exists() { + DBG_DEBUG!("Cleaning up socket from previous invocations"); + if let Err(_) = std::fs::remove_file(sock_path) { + DBG_ERR!("Failed removing socket"); + } + } // Initialize the Himmelblau cache let private_cache_path = match lp.private_path("himmelblau.tdb") {