Skip to content

Commit d9050c3

Browse files
committed
While start the shim fail, ensure the socket file has been remove
Discovered socket file leak when set_cgroup_ond_oom_store execution failed. Signed-off-by: jokemanfire <[email protected]>
1 parent 9d9cc05 commit d9050c3

File tree

1 file changed

+10
-2
lines changed
  • crates/shim/src/asynchronous

1 file changed

+10
-2
lines changed

crates/shim/src/asynchronous/mod.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,18 @@ pub async fn spawn(opts: StartOpts, grouping: &str, vars: Vec<(&str, &str)>) ->
344344
command.arg("-debug");
345345
}
346346
command.envs(vars);
347+
let result = command.spawn().map_err(io_error!(e, "spawn shim"));
348+
if let Err(e) = result {
349+
remove_socket(&address).await?;
350+
return Err(e);
351+
}
352+
let child = result?;
347353

348-
let _child = command.spawn().map_err(io_error!(e, "spawn shim"))?;
349354
#[cfg(target_os = "linux")]
350-
crate::cgroup::set_cgroup_and_oom_score(_child.id())?;
355+
if let Err(e) = crate::cgroup::set_cgroup_and_oom_score(child.id()) {
356+
remove_socket(&address).await?;
357+
return Err(e);
358+
}
351359
Ok(address)
352360
}
353361

0 commit comments

Comments
 (0)