tracing fixes in unix poll; add some missing debug impls

This commit is contained in:
Pat Hickey
2020-08-25 11:29:34 -07:00
parent 963fe37eea
commit 930912f783
3 changed files with 16 additions and 4 deletions

View File

@@ -18,6 +18,12 @@ impl EntryHandle {
} }
} }
impl std::fmt::Debug for EntryHandle {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("EntryHandle").field("opaque", &()).finish()
}
}
impl From<Box<dyn Handle>> for EntryHandle { impl From<Box<dyn Handle>> for EntryHandle {
fn from(handle: Box<dyn Handle>) -> Self { fn from(handle: Box<dyn Handle>) -> Self {
Self(handle.into()) Self(handle.into())

View File

@@ -9,6 +9,7 @@ pub(crate) struct ClockEventData {
pub(crate) userdata: types::Userdata, pub(crate) userdata: types::Userdata,
} }
#[derive(Debug)]
pub(crate) struct FdEventData { pub(crate) struct FdEventData {
pub(crate) handle: EntryHandle, pub(crate) handle: EntryHandle,
pub(crate) r#type: types::Eventtype, pub(crate) r#type: types::Eventtype,

View File

@@ -38,7 +38,10 @@ pub(crate) fn oneoff(
let delay = timeout.delay / 1_000_000; // poll syscall requires delay to expressed in milliseconds let delay = timeout.delay / 1_000_000; // poll syscall requires delay to expressed in milliseconds
delay.try_into().unwrap_or(libc::c_int::max_value()) delay.try_into().unwrap_or(libc::c_int::max_value())
}); });
tracing::debug!("poll_oneoff poll_timeout = {:?}", poll_timeout); tracing::debug!(
poll_timeout = tracing::field::debug(poll_timeout),
"poll_oneoff"
);
let ready = loop { let ready = loop {
match poll(&mut poll_fds, poll_timeout) { match poll(&mut poll_fds, poll_timeout) {
@@ -91,15 +94,17 @@ fn handle_fd_event(
} }
for (fd_event, poll_fd) in ready_events { for (fd_event, poll_fd) in ready_events {
tracing::debug!("poll_oneoff_handle_fd_event poll_fd = {:?}", poll_fd); tracing::debug!(
poll_fd = tracing::field::debug(poll_fd),
poll_event = tracing::field::debug(&fd_event),
"poll_oneoff handle_fd_event"
);
let revents = match poll_fd.revents() { let revents = match poll_fd.revents() {
Some(revents) => revents, Some(revents) => revents,
None => continue, None => continue,
}; };
tracing::debug!("poll_oneoff_handle_fd_event revents = {:?}", revents);
let nbytes = if fd_event.r#type == types::Eventtype::FdRead { let nbytes = if fd_event.r#type == types::Eventtype::FdRead {
query_nbytes(fd_event.handle)? query_nbytes(fd_event.handle)?
} else { } else {