mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-04-18 07:51:29 +03:00
fix crash due to dropped fd (#167)
This commit is contained in:
committed by
GitHub
parent
22dc33367b
commit
68361b25d1
@@ -1,11 +1,10 @@
|
|||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use futures_core::Stream;
|
use futures_core::Stream;
|
||||||
use memmap::MmapOptions;
|
|
||||||
use std::{
|
use std::{
|
||||||
collections::VecDeque,
|
collections::VecDeque,
|
||||||
env,
|
env,
|
||||||
io::{self, ErrorKind},
|
io::{self, ErrorKind},
|
||||||
os::fd::{AsFd, OwnedFd, RawFd},
|
os::fd::{AsFd, RawFd},
|
||||||
pin::Pin,
|
pin::Pin,
|
||||||
task::{ready, Context, Poll},
|
task::{ready, Context, Poll},
|
||||||
};
|
};
|
||||||
@@ -14,7 +13,7 @@ use tokio::io::unix::AsyncFd;
|
|||||||
use std::{
|
use std::{
|
||||||
fs::File,
|
fs::File,
|
||||||
io::{BufWriter, Write},
|
io::{BufWriter, Write},
|
||||||
os::unix::prelude::{AsRawFd, FromRawFd},
|
os::unix::prelude::AsRawFd,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -108,7 +107,7 @@ struct State {
|
|||||||
client_for_window: Vec<(Arc<Window>, CaptureHandle)>,
|
client_for_window: Vec<(Arc<Window>, CaptureHandle)>,
|
||||||
focused: Option<(Arc<Window>, CaptureHandle)>,
|
focused: Option<(Arc<Window>, CaptureHandle)>,
|
||||||
g: Globals,
|
g: Globals,
|
||||||
wayland_fd: OwnedFd,
|
wayland_fd: RawFd,
|
||||||
read_guard: Option<ReadEventsGuard>,
|
read_guard: Option<ReadEventsGuard>,
|
||||||
qh: QueueHandle<Self>,
|
qh: QueueHandle<Self>,
|
||||||
pending_events: VecDeque<(CaptureHandle, Event)>,
|
pending_events: VecDeque<(CaptureHandle, Event)>,
|
||||||
@@ -123,7 +122,7 @@ struct Inner {
|
|||||||
|
|
||||||
impl AsRawFd for Inner {
|
impl AsRawFd for Inner {
|
||||||
fn as_raw_fd(&self) -> RawFd {
|
fn as_raw_fd(&self) -> RawFd {
|
||||||
self.state.wayland_fd.as_raw_fd()
|
self.state.wayland_fd
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,10 +307,7 @@ impl WaylandInputCapture {
|
|||||||
// flush outgoing events
|
// flush outgoing events
|
||||||
queue.flush()?;
|
queue.flush()?;
|
||||||
|
|
||||||
// prepare reading wayland events
|
let wayland_fd = queue.as_fd().as_raw_fd();
|
||||||
let read_guard = queue.prepare_read().unwrap(); // there can not yet be events to dispatch
|
|
||||||
let wayland_fd = read_guard.connection_fd().try_clone_to_owned().unwrap();
|
|
||||||
std::mem::drop(read_guard);
|
|
||||||
|
|
||||||
let mut state = State {
|
let mut state = State {
|
||||||
pointer: None,
|
pointer: None,
|
||||||
@@ -820,15 +816,6 @@ impl Dispatch<WlKeyboard, ()> for State {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wl_keyboard::Event::Keymap {
|
|
||||||
format: _,
|
|
||||||
fd,
|
|
||||||
size: _,
|
|
||||||
} => {
|
|
||||||
let fd = unsafe { &File::from_raw_fd(fd.as_raw_fd()) };
|
|
||||||
let _mmap = unsafe { MmapOptions::new().map_copy(fd).unwrap() };
|
|
||||||
// TODO keymap
|
|
||||||
}
|
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user