From 15ae2c27db10101bd690fa81093e995b16379675 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Fri, 29 Sep 2023 18:44:24 -0700 Subject: [PATCH] Fix double `close` when calling `xkb::Keymap::new_from_fd` `strace ./target/debug/examples/simple_window 2>&1| grep EBADF` shows this error before this change. `new_from_fd` calls `File::from` on the fd, which results in closing it on drop. --- src/seat/keyboard/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/seat/keyboard/mod.rs b/src/seat/keyboard/mod.rs index 9a9aca413..61f40ccfd 100644 --- a/src/seat/keyboard/mod.rs +++ b/src/seat/keyboard/mod.rs @@ -4,7 +4,7 @@ use std::{ fmt::Debug, marker::PhantomData, num::NonZeroU32, - os::unix::io::AsRawFd, + os::unix::io::IntoRawFd, sync::{ atomic::{AtomicBool, Ordering}, Arc, Mutex, @@ -534,7 +534,7 @@ where match unsafe { xkb::Keymap::new_from_fd( &context, - fd.as_raw_fd(), + fd.into_raw_fd(), size as usize, xkb::KEYMAP_FORMAT_TEXT_V1, xkb::COMPILE_NO_FLAGS,