diff --git a/Cargo.lock b/Cargo.lock index 28d0778c05ebf..e36d1f2088817 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5158,7 +5158,7 @@ dependencies = [ [[package]] name = "tokio-epoll-uring" version = "0.1.0" -source = "git+https://github.com/neondatabase/tokio-epoll-uring.git?branch=problame/generic-owned-fd#c57c5867ae9511f2f2d9ba170f493bbab73a2eee" +source = "git+https://github.com/neondatabase/tokio-epoll-uring.git?branch=problame/generic-owned-fd#fe30c3e8cf8197bd7655e79906d346e5605d96b6" dependencies = [ "futures", "once_cell", @@ -5714,7 +5714,7 @@ dependencies = [ [[package]] name = "uring-common" version = "0.1.0" -source = "git+https://github.com/neondatabase/tokio-epoll-uring.git?branch=problame/generic-owned-fd#c57c5867ae9511f2f2d9ba170f493bbab73a2eee" +source = "git+https://github.com/neondatabase/tokio-epoll-uring.git?branch=problame/generic-owned-fd#fe30c3e8cf8197bd7655e79906d346e5605d96b6" dependencies = [ "io-uring", "libc", diff --git a/pageserver/src/virtual_file.rs b/pageserver/src/virtual_file.rs index e99d375d3ae16..bf2fe59bbf21e 100644 --- a/pageserver/src/virtual_file.rs +++ b/pageserver/src/virtual_file.rs @@ -16,7 +16,7 @@ use camino::{Utf8Path, Utf8PathBuf}; use once_cell::sync::OnceCell; use std::fs::{self, File}; use std::io::{Error, ErrorKind, Seek, SeekFrom}; -use std::os::fd::{AsRawFd, FromRawFd, OwnedFd, RawFd}; +use std::os::fd::{AsRawFd, FromRawFd, OwnedFd, RawFd, IntoRawFd}; use std::os::unix::fs::FileExt; use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use tokio::sync::{RwLock, RwLockReadGuard, RwLockWriteGuard}; @@ -713,7 +713,9 @@ impl FileGuard { // - lifetime of the fd: `file` doesn't outlive the OwnedFd stored in `self`. // - `&` usage below: `self` is `&`, hence Rust typesystem guarantees there are is no `&mut` let file = unsafe { File::from_raw_fd(self.as_ref().as_raw_fd()) }; - with(&file) + let res = with(&file); + let _ = file.into_raw_fd(); + res } // TODO: switch to tokio-epoll-uring native operations. fn with_std_file_mut(&mut self, with: F) -> R @@ -724,7 +726,9 @@ impl FileGuard { // - lifetime of the fd: `file` doesn't outlive the OwnedFd stored in `self`. // - &mut usage below: `self` is `&mut`, hence this call is the only task/thread that has control over the underlying fd let mut file = unsafe { File::from_raw_fd(self.as_ref().as_raw_fd()) }; - with(&mut file) + let res = with(&mut file); + let _ = file.into_raw_fd(); + res } }