Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src-tauri/src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ impl Pipeline {

fn shutdown(&mut self) -> Option<VirtualCamera> {
self.shared.stop.store(true, Ordering::SeqCst);
// Unblocks the read the pipeline thread may be sitting in.
// Unblocks the read the pipeline thread may be sitting in. While the server is still
// starting there is no socket yet; the thread sees the flag at its first packet instead.
if let Some(s) = self.shared.video.lock().unwrap().as_ref() {
let _ = s.shutdown(Shutdown::Both);
}
Expand Down Expand Up @@ -275,6 +276,11 @@ fn stream(
let mut stall_timeout_set = false;

loop {
// A stop that came while the server was starting had no socket to shut down, and a
// healthy stream never fails a read, so the flag is checked on every packet too.
if shared.stop.load(Ordering::SeqCst) {
return Ok(());
}
let packet = match protocol::read_packet(&mut reader) {
Ok(p) => p,
Err(_) if shared.stop.load(Ordering::SeqCst) => return Ok(()),
Expand Down
Loading