mirror of
https://github.com/ilya-zlobintsev/LACT.git
synced 2025-02-25 18:55:26 -06:00
Fix sockets not cleaning up, leading to a file descriptor leak
This commit is contained in:
parent
d76b23a248
commit
862a46d754
@ -1,3 +1,5 @@
|
||||
use nix::unistd;
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::gpu_controller::{FanControlInfo, GpuStats};
|
||||
use crate::gpu_controller::{GpuInfo, PowerProfile};
|
||||
@ -50,6 +52,11 @@ impl DaemonConnection {
|
||||
}
|
||||
}
|
||||
}
|
||||
nix::sys::socket::shutdown(socket, nix::sys::socket::Shutdown::Both)
|
||||
.expect("Could not shut down");
|
||||
|
||||
nix::unistd::close(socket).expect("Failed to close");
|
||||
|
||||
let result: Result<DaemonResponse, DaemonResponse> =
|
||||
bincode::deserialize(&buffer).expect("failed to deserialize message");
|
||||
|
||||
@ -80,6 +87,11 @@ impl DaemonConnection {
|
||||
|
||||
let buffer = Daemon::read_buffer(socket);
|
||||
|
||||
nix::sys::socket::shutdown(socket, nix::sys::socket::Shutdown::Both)
|
||||
.expect("Failed to shut down");
|
||||
|
||||
nix::unistd::close(socket).expect("Failed to close");
|
||||
|
||||
bincode::deserialize(&buffer).expect("failed to deserialize message")
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user