diff --git a/core/io/io_uring.rs b/core/io/io_uring.rs index e37c9f6c3..f98f6f36f 100644 --- a/core/io/io_uring.rs +++ b/core/io/io_uring.rs @@ -8,6 +8,7 @@ use std::io::ErrorKind; use std::os::fd::AsFd; use std::os::unix::io::AsRawFd; use std::rc::Rc; +use std::sync::Arc; use thiserror::Error; use tracing::{debug, trace}; @@ -35,6 +36,9 @@ pub struct UringIO { inner: Rc>, } +unsafe impl Send for UringIO {} +unsafe impl Sync for UringIO {} + struct WrappedIOUring { ring: io_uring::IoUring, pending_ops: usize, @@ -132,7 +136,7 @@ impl WrappedIOUring { } impl IO for UringIO { - fn open_file(&self, path: &str, flags: OpenFlags, direct: bool) -> Result> { + fn open_file(&self, path: &str, flags: OpenFlags, direct: bool) -> Result> { trace!("open_file(path = {})", path); let file = std::fs::File::options() .read(true) @@ -148,7 +152,7 @@ impl IO for UringIO { Err(error) => debug!("Error {error:?} returned when setting O_DIRECT flag to read file. The performance of the system may be affected"), } } - let uring_file = Rc::new(UringFile { + let uring_file = Arc::new(UringFile { io: self.inner.clone(), file, }); @@ -203,6 +207,9 @@ pub struct UringFile { file: std::fs::File, } +unsafe impl Send for UringFile {} +unsafe impl Sync for UringFile {} + impl File for UringFile { fn lock_file(&self, exclusive: bool) -> Result<()> { let fd = self.file.as_fd(); @@ -260,7 +267,7 @@ impl File for UringFile { Ok(()) } - fn pwrite(&self, pos: usize, buffer: Rc>, c: Completion) -> Result<()> { + fn pwrite(&self, pos: usize, buffer: Arc>, c: Completion) -> Result<()> { let mut io = self.io.borrow_mut(); let fd = io_uring::types::Fd(self.file.as_raw_fd()); let write = { diff --git a/core/lib.rs b/core/lib.rs index d3f3711cd..688de84c9 100644 --- a/core/lib.rs +++ b/core/lib.rs @@ -172,7 +172,7 @@ impl Database { buffer_pool, )?); let conn = Rc::new(Connection { - db: self.clone(), + _db: self.clone(), pager: pager.clone(), schema: self.schema.clone(), header: self.header.clone(), @@ -239,7 +239,7 @@ pub fn maybe_init_database_file(file: &Arc, io: &Arc) -> Resul } pub struct Connection { - db: Arc, + _db: Arc, pager: Rc, schema: Arc>, header: Arc>,