From 35372b53373dba6b5cc4f549dcbd71d51a962074 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Wed, 24 Jul 2024 16:27:30 +0200 Subject: [PATCH] daemon: boxed FnOnce has been usable for a while While technically an API break, we don't use the public API for this anywhere and the trait we're changing is explicitly marked as `#[doc(hidden)]`. Signed-off-by: Wolfgang Bumiller --- proxmox-daemon/src/server.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/proxmox-daemon/src/server.rs b/proxmox-daemon/src/server.rs index 19d81905..70923534 100644 --- a/proxmox-daemon/src/server.rs +++ b/proxmox-daemon/src/server.rs @@ -16,8 +16,7 @@ use nix::unistd::{fork, ForkResult}; use proxmox_sys::fd::fd_change_cloexec; use proxmox_sys::fs::CreateOptions; -// Unfortunately FnBox is nightly-only and Box is unusable, so just use Box... -type BoxedStoreFunc = Box Result + UnwindSafe + Send>; +type BoxedStoreFunc = Box Result + UnwindSafe + Send>; // Helper trait to "store" something in the environment to be re-used after re-executing the // service on a reload. @@ -76,7 +75,7 @@ impl Reloader { } fn pre_exec(self) -> Result<(), Error> { - for mut item in self.pre_exec { + for item in self.pre_exec { std::env::set_var(item.name, (item.store_fn)()?); } Ok(()) @@ -232,14 +231,13 @@ impl Reloader { } fn fd_store_func(fd: RawFd) -> Result { - let mut fd_opt = Some(unsafe { + let fd = unsafe { OwnedFd::from_raw_fd(nix::fcntl::fcntl( fd, nix::fcntl::FcntlArg::F_DUPFD_CLOEXEC(0), )?) - }); + }; Ok(Box::new(move || { - let fd = fd_opt.take().unwrap(); fd_change_cloexec(fd.as_raw_fd(), false)?; Ok(fd.into_raw_fd().to_string()) }))