mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-03-23 13:10:56 +03:00
ignore requests with capture / emulation disabled
otherwise the server would hang when trying to enable clients
This commit is contained in:
@@ -61,9 +61,12 @@ async fn capture_task(
|
||||
}
|
||||
|
||||
// allow cancellation
|
||||
tokio::select! {
|
||||
_ = server.capture_notified() => {},
|
||||
_ = server.cancelled() => break,
|
||||
loop {
|
||||
tokio::select! {
|
||||
_ = notify_rx.recv() => continue, /* need to ignore requests here! */
|
||||
_ = server.capture_notified() => break,
|
||||
_ = server.cancelled() => return,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,26 +57,22 @@ async fn emulation_task(
|
||||
capture_tx: Sender<CaptureEvent>,
|
||||
) {
|
||||
loop {
|
||||
match do_emulation(&server, &mut rx, &mut udp_rx, &sender_tx, &capture_tx).await {
|
||||
Ok(()) => {}
|
||||
Err(e) => {
|
||||
log::warn!("input emulation exited: {e}");
|
||||
}
|
||||
if let Err(e) = do_emulation(&server, &mut rx, &mut udp_rx, &sender_tx, &capture_tx).await {
|
||||
log::warn!("input emulation exited: {e}");
|
||||
}
|
||||
server.set_emulation_status(Status::Disabled);
|
||||
|
||||
if server.notifies.cancel.is_cancelled() {
|
||||
if server.is_cancelled() {
|
||||
break;
|
||||
}
|
||||
log::info!("waiting for user to request input emulation ...");
|
||||
|
||||
// allow cancellation
|
||||
tokio::select! {
|
||||
_ = server.emulation_notified() => {},
|
||||
_ = server.cancelled() => break,
|
||||
loop {
|
||||
tokio::select! {
|
||||
_ = rx.recv() => continue, /* need to ignore requests here! */
|
||||
_ = server.emulation_notified() => break,
|
||||
_ = server.cancelled() => return,
|
||||
}
|
||||
}
|
||||
|
||||
log::info!("... done");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user