From d61b878d03c3381a839f49578a6939e6e4e188d4 Mon Sep 17 00:00:00 2001 From: vasilito Date: Fri, 17 Jul 2026 18:13:54 +0900 Subject: [PATCH] =?UTF-8?q?sessiond:=20syscall-level=20DIAG=20=E2=80=94=20?= =?UTF-8?q?register=20pipe=20vs=20uds=5Fstream=20fd=20with=20/scheme/event?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../redbear-sessiond/source/src/main.rs | 55 ++++++++++++++----- 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/local/recipes/system/redbear-sessiond/source/src/main.rs b/local/recipes/system/redbear-sessiond/source/src/main.rs index 420a98f43f..f68ba1f1da 100644 --- a/local/recipes/system/redbear-sessiond/source/src/main.rs +++ b/local/recipes/system/redbear-sessiond/source/src/main.rs @@ -224,21 +224,50 @@ fn main() { println!("{}", usage()); } Ok(Command::Run) => { - // SESSIOND_DIAG (temporary): pinpoint which tokio runtime config - // EINVALs on Redox. Each line shows in the boot console. - macro_rules! diag { - ($label:expr, $build:expr) => { - match $build { - Ok(rt) => { eprintln!("SESSIOND_DIAG: {} OK", $label); drop(rt); } - Err(e) => eprintln!("SESSIOND_DIAG: {} FAIL {}", $label, e), + // SESSIOND_DIAG (temporary): the I/O reactor (enable_all) EINVALs. + // Confirm whether registering an ipcd uds_stream fd (used by tokio's + // signal-driver receiver) with /scheme/event is what fails, vs a + // kernel pipe fd (used by the mio waker, which should succeed). + { + use std::os::fd::AsRawFd; + use syscall::data::Event; + use syscall::flag::EventFlags; + const O_RDWR_S: i32 = 0x0003_0000; + const O_RDONLY_S: i32 = 0x0001_0000; + fn register(epfd: usize, fd: usize) -> syscall::Result { + let ev = Event { id: fd, flags: EventFlags::EVENT_READ, data: 0 }; + let bytes = unsafe { + core::slice::from_raw_parts( + (&ev as *const Event) as *const u8, + core::mem::size_of::(), + ) + }; + syscall::write(epfd, bytes) + } + match libredox::call::open("/scheme/event", O_RDWR_S, 0) { + Ok(epfd) => { + eprintln!("SESSIOND_DIAG: open /scheme/event OK"); + match libredox::call::open("/scheme/pipe", O_RDONLY_S, 0) { + Ok(pfd) => { + eprintln!("SESSIOND_DIAG: register PIPE fd = {:?}", register(epfd, pfd)); + let _ = libredox::call::close(pfd); + } + Err(e) => eprintln!("SESSIOND_DIAG: open /scheme/pipe FAIL {:?}", e), + } + match std::os::unix::net::UnixStream::pair() { + Ok((a, _b)) => { + eprintln!( + "SESSIOND_DIAG: register UDS_STREAM fd = {:?}", + register(epfd, a.as_raw_fd() as usize) + ); + } + Err(e) => eprintln!("SESSIOND_DIAG: UnixStream::pair FAIL {}", e), + } + let _ = libredox::call::close(epfd); } - }; + Err(e) => eprintln!("SESSIOND_DIAG: open /scheme/event FAIL {:?}", e), + } } - diag!("ct-none", RuntimeBuilder::new_current_thread().build()); - diag!("ct-time", RuntimeBuilder::new_current_thread().enable_time().build()); - diag!("ct-all", RuntimeBuilder::new_current_thread().enable_all().build()); - diag!("mt-none", RuntimeBuilder::new_multi_thread().build()); - diag!("mt-all", RuntimeBuilder::new_multi_thread().enable_all().build()); let runtime = match RuntimeBuilder::new_multi_thread().enable_all().build() { Ok(runtime) => runtime,