Skip to content

Commit f56a709

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 f56a709

File tree

1 file changed

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

1 file changed

+12
-2
lines changed

crates/shim/src/asynchronous/mod.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,20 @@ 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+
let _child = match result {
349+
Ok(child) => child,
350+
Err(e) => {
351+
remove_socket(&address).await?;
352+
return Err(e);
353+
}
354+
};
347355

348-
let _child = command.spawn().map_err(io_error!(e, "spawn shim"))?;
349356
#[cfg(target_os = "linux")]
350-
crate::cgroup::set_cgroup_and_oom_score(_child.id())?;
357+
if let Err(e) = crate::cgroup::set_cgroup_and_oom_score(_child.id()) {
358+
remove_socket(&address).await?;
359+
return Err(e);
360+
}
351361
Ok(address)
352362
}
353363

0 commit comments

Comments
 (0)