1
0
Fork 0
forked from wry/wry

all: fix memory leaks

This commit is contained in:
Julian Orth 2022-05-02 22:11:59 +02:00
parent e212e0b8b1
commit 9904717c71
18 changed files with 149 additions and 10 deletions

View file

@ -74,6 +74,12 @@ pub enum ForkerError {
}
impl ForkerProxy {
pub fn clear(&self) {
self.task_in.take();
self.task_out.take();
self.task_proc.take();
}
pub fn create() -> Result<Self, ForkerError> {
let (parent, child) = match uapi::socketpair(
c::AF_UNIX,
@ -240,8 +246,8 @@ impl ForkerProxy {
}
if let Err(e) = io.write_msg(msg).await {
log::error!("Could not write to the ol' forker: {}", ErrorFmt(e));
self.clear();
state.forker.set(None);
self.task_out.take();
return;
}
}
@ -258,9 +264,8 @@ impl ForkerProxy {
let _ = uapi::waitpid(self.pid, 0);
}
log::error!("The ol' forker died. Cannot spawn further processes.");
self.clear();
state.forker.set(None);
self.task_out.take();
self.task_proc.take();
}
}