mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-04-18 10:51:29 +03:00
fix potential unterminated emulation session
This commit is contained in:
@@ -291,11 +291,11 @@ impl EmulationProxy {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// create active handles
|
// create active handles
|
||||||
for &handle in handles.values() {
|
if let Err(e) =
|
||||||
tokio::select! {
|
Self::create_clients(&mut emulation, handles.values().copied(), request_rx).await
|
||||||
_ = emulation.create(handle) => {},
|
{
|
||||||
_ = wait_for_termination(request_rx) => return Ok(()),
|
emulation.terminate().await;
|
||||||
}
|
return Err(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
let res = Self::do_emulation_session(&mut emulation, handles, next_id, request_rx).await;
|
let res = Self::do_emulation_session(&mut emulation, handles, next_id, request_rx).await;
|
||||||
@@ -304,6 +304,20 @@ impl EmulationProxy {
|
|||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn create_clients(
|
||||||
|
emulation: &mut InputEmulation,
|
||||||
|
handles: impl Iterator<Item = EmulationHandle>,
|
||||||
|
request_rx: &mut Receiver<ProxyRequest>,
|
||||||
|
) -> Result<(), InputEmulationError> {
|
||||||
|
for handle in handles {
|
||||||
|
tokio::select! {
|
||||||
|
_ = emulation.create(handle) => {},
|
||||||
|
_ = wait_for_termination(request_rx) => return Ok(()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
async fn do_emulation_session(
|
async fn do_emulation_session(
|
||||||
emulation: &mut InputEmulation,
|
emulation: &mut InputEmulation,
|
||||||
handles: &mut HashMap<SocketAddr, EmulationHandle>,
|
handles: &mut HashMap<SocketAddr, EmulationHandle>,
|
||||||
|
|||||||
Reference in New Issue
Block a user