mirror of
https://gitlab.com/marcandre.lureau/qemu-display.git
synced 2024-12-22 05:35:20 +00:00
rdp: disconnect update listener when the client is gone
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
parent
3b282c440a
commit
2432ee97f3
@ -2,7 +2,10 @@
|
||||
use crate::win32::Fd;
|
||||
#[cfg(unix)]
|
||||
use std::os::unix::net::UnixStream;
|
||||
use std::{convert::TryFrom, sync::RwLock};
|
||||
use std::{
|
||||
convert::TryFrom,
|
||||
sync::{Arc, RwLock},
|
||||
};
|
||||
#[cfg(windows)]
|
||||
use uds_windows::UnixStream;
|
||||
#[cfg(unix)]
|
||||
@ -50,7 +53,7 @@ pub trait Console {
|
||||
}
|
||||
|
||||
#[derive(derivative::Derivative)]
|
||||
#[derivative(Debug)]
|
||||
#[derivative(Debug, Clone)]
|
||||
pub struct Console {
|
||||
#[derivative(Debug = "ignore")]
|
||||
pub proxy: ConsoleProxy<'static>,
|
||||
@ -60,7 +63,7 @@ pub struct Console {
|
||||
pub mouse: MouseProxy<'static>,
|
||||
#[derivative(Debug = "ignore")]
|
||||
pub multi_touch: MultiTouchProxy<'static>,
|
||||
listener: RwLock<Option<Connection>>,
|
||||
listener: Arc<RwLock<Option<Connection>>>,
|
||||
#[cfg(windows)]
|
||||
peer_pid: u32,
|
||||
}
|
||||
@ -83,7 +86,7 @@ impl Console {
|
||||
keyboard,
|
||||
mouse,
|
||||
multi_touch,
|
||||
listener: RwLock::new(None),
|
||||
listener: Arc::new(RwLock::new(None)),
|
||||
#[cfg(windows)]
|
||||
peer_pid,
|
||||
})
|
||||
|
@ -30,6 +30,13 @@ pub struct DisplayHandler {
|
||||
|
||||
struct DisplayUpdates {
|
||||
receiver: queue::Receiver,
|
||||
console: Console,
|
||||
}
|
||||
|
||||
impl Drop for DisplayUpdates {
|
||||
fn drop(&mut self) {
|
||||
self.console.unregister_listener();
|
||||
}
|
||||
}
|
||||
|
||||
impl DisplayHandler {
|
||||
@ -52,7 +59,8 @@ impl DisplayHandler {
|
||||
#[cfg(any(windows, unix))]
|
||||
self.console.set_map_listener(listener.clone()).await?;
|
||||
|
||||
Ok(DisplayUpdates { receiver })
|
||||
let console = self.console.clone();
|
||||
Ok(DisplayUpdates { receiver, console })
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user