sessiond: syscall-level DIAG — register pipe vs uds_stream fd with /scheme/event
This commit is contained in:
@@ -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<usize> {
|
||||
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::<Event>(),
|
||||
)
|
||||
};
|
||||
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,
|
||||
|
||||
Reference in New Issue
Block a user