From cb47da4910c846bae990ba04cf4d2dd94d0301ff Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Tue, 27 Feb 2018 16:55:17 -0800 Subject: sys_util: fix handling EINTR of C system functions System functions have 2 ways of signalling errors, either via returning -1 as result, and setting errno, or directly returning error code, and we can not distinguish automatically between the 2 options when using InterruptibleResult trait for i32 values. Let's remove this trait for i32 and create 2 explicit macros: handle_eintr_rc and handle_eintr_errno. TEST=cargo test --features plugin; cargo test -p sys_util BUG=None Change-Id: I1dc8e3c023e7bf7875ac3536703eb71fa3206b7b Signed-off-by: Dmitry Torokhov Reviewed-on: https://chromium-review.googlesource.com/940612 Reviewed-by: Zach Reizner --- sys_util/src/poll.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'sys_util/src/poll.rs') diff --git a/sys_util/src/poll.rs b/sys_util/src/poll.rs index 2e28514..d6c3d4a 100644 --- a/sys_util/src/poll.rs +++ b/sys_util/src/poll.rs @@ -115,11 +115,11 @@ impl Poller { // Safe because poll is given the correct length of properly initialized pollfds, and we // check the return result. let ret = unsafe { - handle_eintr!(ppoll(self.pollfds.as_mut_ptr(), - self.pollfds.len() as nfds_t, - &mut timeout_spec, - null(), - 0)) + handle_eintr_errno!(ppoll(self.pollfds.as_mut_ptr(), + self.pollfds.len() as nfds_t, + &mut timeout_spec, + null(), + 0)) }; *timeout = Duration::new(timeout_spec.tv_sec as u64, timeout_spec.tv_nsec as u32); -- cgit 1.4.1