release capture only if no active capture at pos

This commit is contained in:
Ferdinand Schober
2024-10-08 14:26:29 +02:00
parent 06d4e8d836
commit 4a64a97273
2 changed files with 28 additions and 7 deletions

View File

@@ -228,6 +228,19 @@ async fn handle_capture_event(
enter_tx.send(handle).expect("channel closed");
}
// incoming connection
if handle >= Service::ENTER_HANDLE_BEGIN {
// if there is no active outgoing connection at the current capture,
// we release the capture
if let Some(pos) = server.get_incoming_pos(handle) {
if server.client_manager.client_at(pos).is_none() {
capture.release().await?;
}
}
// we dont care about events from incoming handles except for releasing the capture
return Ok(());
}
// activated a new client
if event == CaptureEvent::Begin && Some(handle) != server.get_active() {
*state = State::WaitingForAck;