FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Squash ENODEV in Device::Drop by hpccc53 · Pull Request #172 · emberian/evdev · GitHub

/ evdev Public
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .rs  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
12 changes: 11 additions & 1 deletion src/sync_stream.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::{
InputId, KeyCode,
};

use libc::ENODEV;
use nix::fcntl;
use std::fs::File;
use std::os::fd::{AsFd, AsRawFd, BorrowedFd, OwnedFd, RawFd};
Expand Down Expand Up @@ -418,7 +419,16 @@ impl Device {
impl Drop for Device {
fn drop(&mut self) {
if let Err(error) = self.ungrab() {
eprintln!("Failed to ungrab device: {error}");
// Ignore when the device has already been closed
// by some external event like device disconnect.
let enodev = error
.raw_os_error()
.map(|errno| errno == ENODEV)
.unwrap_or_default();

if !enodev {
eprintln!("Failed to ungrab device: {error}");
}
}
}
}
Expand Down
Loading

Back | FazBrowse Home | New Git URL