From 8ba33f247386a2869cff617361bdd70b95e2315a Mon Sep 17 00:00:00 2001 From: Victor Brekenfeld Date: Sun, 19 Apr 2020 01:14:25 +0200 Subject: [PATCH] anvil: Report errors of failed device initializations --- anvil/src/udev.rs | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/anvil/src/udev.rs b/anvil/src/udev.rs index 5fc1c81..b6bf30d 100644 --- a/anvil/src/udev.rs +++ b/anvil/src/udev.rs @@ -411,9 +411,29 @@ impl UdevHandler for UdevHandlerImpl OFlag::O_RDWR | OFlag::O_CLOEXEC | OFlag::O_NOCTTY | OFlag::O_NONBLOCK, ) .ok() - .and_then(|fd| LegacyDrmDevice::new(SessionFd(fd), self.logger.clone()).ok()) - .and_then(|drm| GbmDevice::new(drm, self.logger.clone()).ok()) - .and_then(|gbm| EglDevice::new(gbm, self.logger.clone()).ok()) + .and_then( + |fd| match LegacyDrmDevice::new(SessionFd(fd), self.logger.clone()) { + Ok(drm) => Some(drm), + Err(err) => { + error!(self.logger, "Skipping drm device, because of error: {}", err); + None + } + }, + ) + .and_then(|drm| match GbmDevice::new(drm, self.logger.clone()) { + Ok(gbm) => Some(gbm), + Err(err) => { + error!(self.logger, "Skipping gbm device, because of error: {}", err); + None + } + }) + .and_then(|gbm| match EglDevice::new(gbm, self.logger.clone()) { + Ok(egl) => Some(egl), + Err(err) => { + error!(self.logger, "Skipping egl device, because of error: {}", err); + None + } + }) { // init hardware acceleration on the primary gpu. #[cfg(feature = "egl")]