node: Remove control socket at the end

This commit is contained in:
Alexis Sellier 2023-01-23 18:15:03 +01:00
parent fd5ac7f6af
commit d324eab377
No known key found for this signature in database
1 changed files with 2 additions and 3 deletions

View File

@ -27,8 +27,6 @@ pub fn listen<P: AsRef<Path>, H: Handle<Error = client::handle::Error>>(
path: P,
mut handle: H,
) -> Result<(), Error> {
// Remove the socket file on startup before rebinding.
fs::remove_file(&path).ok();
fs::create_dir_all(
path.as_ref()
.parent()
@ -39,7 +37,7 @@ pub fn listen<P: AsRef<Path>, H: Handle<Error = client::handle::Error>>(
log::info!("Binding control socket {}..", path.as_ref().display());
// TODO: Move socket binding to main thread.
let listener = UnixListener::bind(path).map_err(Error::Bind)?;
let listener = UnixListener::bind(&path).map_err(Error::Bind)?;
for incoming in listener.incoming() {
match incoming {
Ok(mut stream) => {
@ -65,6 +63,7 @@ pub fn listen<P: AsRef<Path>, H: Handle<Error = client::handle::Error>>(
}
}
log::debug!("Exiting control loop..");
fs::remove_file(&path).ok();
Ok(())
}