diff --git a/Cargo.toml b/Cargo.toml index 16ab7321..aa05ef4e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ipc-channel" -version = "0.22.0" +version = "0.23.0" description = "A multiprocess drop-in replacement for Rust channels" authors = ["The Servo Project Developers"] license = "MIT OR Apache-2.0" @@ -42,7 +42,7 @@ crossbeam-channel = "0.5" futures-channel = { version = "0.3.32", optional = true } futures-core = { version = "0.3.32", optional = true } libc = "0.2.162" -postcard = {version = "1.1", default-features = false, features = ["use-std"]} +postcard = { version = "1.1", default-features = false, features = ["use-std"] } serde_core = "1.0" thiserror = "2.0.12" uuid = { version = "1", features = ["v4"] } @@ -53,7 +53,7 @@ rustc-hash = "2.1" tempfile = "3.4" [target.'cfg(target_os = "macos")'.dependencies] -rand = "0.9" +rand = "0.10" [dev-dependencies] serde = { version = "1.0", features = ["rc"] } @@ -61,10 +61,10 @@ crossbeam-utils = "0.8" futures-test = "0.3" static_assertions = "1.1.0" criterion = { version = "0.5", features = ["html_reports"] } -rand = "0.9.2" +rand = "0.10" [target.'cfg(target_os = "windows")'.dependencies.windows] -version = "0.61" +version = "0.62" features = [ "Win32_Foundation", "Win32_System_WindowsProgramming", diff --git a/src/platform/macos/mod.rs b/src/platform/macos/mod.rs index a7303a23..f73c75af 100644 --- a/src/platform/macos/mod.rs +++ b/src/platform/macos/mod.rs @@ -15,7 +15,7 @@ use self::mach_sys::{mach_port_right_t, mach_port_t, mach_task_self_, vm_inherit use crate::ipc::IpcMessage; use libc::{self, c_char, c_uint, c_void, size_t}; -use rand::{self, Rng}; +use rand::{self, RngExt}; use std::cell::Cell; use std::convert::TryInto; use std::ffi::CString; diff --git a/src/platform/windows/mod.rs b/src/platform/windows/mod.rs index 7ec6f645..009d32f7 100644 --- a/src/platform/windows/mod.rs +++ b/src/platform/windows/mod.rs @@ -1114,7 +1114,7 @@ fn write_buf(handle: &WinHandle, bytes: &[u8], atomic: AtomicMode) -> Result<(), sz, written, total, - WinError::from_win32() + WinError::from_thread() ); }, } @@ -1482,21 +1482,21 @@ impl OsIpcSender { full_message.extend_from_slice(header_bytes); } - if big_data_sender.is_none() { - full_message.extend_from_slice(data); + if let Some(big_data_sender) = big_data_sender { full_message.extend_from_slice(&oob_data); assert!(full_message.len() == full_in_band_len); - // Write needs to be atomic, since otherwise concurrent sending - // could result in parts of different messages getting intermixed, - // and the receiver would not be able to extract the individual messages. write_buf(&self.handle, &full_message, AtomicMode::Atomic)?; + big_data_sender.send_raw(data)?; } else { + full_message.extend_from_slice(data); full_message.extend_from_slice(&oob_data); assert!(full_message.len() == full_in_band_len); + // Write needs to be atomic, since otherwise concurrent sending + // could result in parts of different messages getting intermixed, + // and the receiver would not be able to extract the individual messages. write_buf(&self.handle, &full_message, AtomicMode::Atomic)?; - big_data_sender.unwrap().send_raw(data)?; } Ok(()) @@ -2022,7 +2022,7 @@ impl OsIpcSharedMemory { unsafe { let address = MapViewOfFile(handle.as_raw(), FILE_MAP_ALL_ACCESS, 0, 0, 0); if address.Value.is_null() { - return Err(WinError::from_win32()); + return Err(WinError::from_thread()); } Ok(OsIpcSharedMemory { diff --git a/src/platform/windows/tests.rs b/src/platform/windows/tests.rs index 7bf790be..62b011c1 100644 --- a/src/platform/windows/tests.rs +++ b/src/platform/windows/tests.rs @@ -5,7 +5,7 @@ use windows::Win32::Foundation::{ CloseHandle, CompareObjectHandles, ERROR_INVALID_HANDLE, HANDLE, INVALID_HANDLE_VALUE, }; use windows::Win32::System::Memory::{CreateFileMappingA, PAGE_READWRITE}; -use windows::Win32::System::Threading::{CreateEventA, GetCurrentProcessId}; +use windows::Win32::System::Threading::CreateEventA; #[test] fn test_recover_handles_empty() { @@ -38,7 +38,7 @@ fn test_recover_handles_duplicates_channel_handles() { assert_eq!(oob.channel_handles.len(), 3); for (i, handle) in oob.channel_handles.iter().enumerate() { assert_ne!(*handle, handles[i]); - assert_ne!(*handle as isize, INVALID_HANDLE_VALUE.0 as isize); + assert_ne!(*handle, INVALID_HANDLE_VALUE.0 as isize); } // Clean up the handles @@ -90,7 +90,7 @@ fn test_recover_handles_duplicates_shmem_handles() { let mut oob = OutOfBandMessage { target_process_id: std::process::id(), channel_handles: vec![], - shmem_handles: handles.clone().into_iter().zip(sizes.into_iter()).collect(), + shmem_handles: handles.clone().into_iter().zip(sizes).collect(), big_data_receiver_handle: None, };