diff --git a/server/src/streaming/direct_io/storage.rs b/server/src/streaming/direct_io/storage.rs index 97e4997d..ae0449af 100644 --- a/server/src/streaming/direct_io/storage.rs +++ b/server/src/streaming/direct_io/storage.rs @@ -115,14 +115,20 @@ impl DirectIOStorage { } pub async fn write_batches(&self, file_path: &str, bytes: Vec) -> Result { - let mut std_file = std::fs::File::options().append(true).custom_flags(libc::O_DIRECT).open(file_path)?; //let mut file = OpenOptions::new().append(true).custom_flags(libc::O_DIRECT).open(file_path).await?; let size = bytes.len() as _; - spawn_blocking(move || { - if let Err(e) = std_file.write_all(&bytes) { - warn!("error writing: {}", e); - } - }).await.unwrap(); + let std_file = std::fs::File::options().append(true).custom_flags(libc::O_DIRECT).open(file_path).unwrap(); + let handle = tokio::spawn(async move{ + Self::foo(std_file, bytes).await; + }); + std::mem::forget(handle); + Ok(size) } + + async fn foo(mut file: std::fs::File, bytes: Vec) { + if let Err(e) = file.write_all(&bytes) { + warn!("error writing: {}", e); + } + } }