Detach during blocking Windows multiprocessing socket I/O (#9093)

Snapshot locked send buffers before waiting and preserve the host-captured Winsock error across VM reattachment.

Assisted-by: OpenAI Codex: model identifier unavailable

Co-authored-by: dot <dot@youknowone.org>
This commit is contained in:
Jeong, YunWonanddot authored and GitHub committed 2026-10-13 20:47:12 +09:00
1 parent e09846b4eb
commit 10cb49430a
1 file changed
+9 -6
+9 -6
View File
@@ -408,19 +408,22 @@ mod _multiprocessing {
#[pyfunction]
fn recv(socket: usize, size: usize, vm: &VirtualMachine) -> PyResult<Vec<u8>> {
let mut buf =
host_multiprocessing::recv_socket(socket as host_multiprocessing::RawSocket, size)
.map_err(|_| vm.new_last_os_error())?;
let mut buf = vm
.allow_threads(|| {
host_multiprocessing::recv_socket(socket as host_multiprocessing::RawSocket, size)
})
.map_err(|error| error.to_pyexception(vm))?;
buf.shrink_to_fit();
Ok(buf)
}
#[pyfunction]
fn send(socket: usize, buf: ArgBytesLike, vm: &VirtualMachine) -> PyResult<core::ffi::c_int> {
buf.with_ref(|b| {
host_multiprocessing::send_socket(socket as host_multiprocessing::RawSocket, b)
let buf = buf.borrow_buf_unlocked(vm)?;
vm.allow_threads(|| {
host_multiprocessing::send_socket(socket as host_multiprocessing::RawSocket, &buf)
})
.map_err(|_| vm.new_last_os_error())
.map_err(|error| error.to_pyexception(vm))
}
}