-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Input & Driver: Fix zombie processes on Unix (#39)
Linux/Unix requires that processes be waited, which is unfortunate as Windows lets us abandon them to the murderous whims of the OS. This PR adds Unix-specific behaviour to send a SIGINT before waiting on the process, and adds an additional thread per call for asset disposal on all platforms. Closes #38. --- * Close processes by SIGINT and wait on Unix This seems to remedy the Linux-specific zombie processes. Addition of nix as a dependency *should* be fine on Windows, since I believe it compiles to an empty crate. * Dispose of Tracks on auxiliary thread This adds a mechanism for the mixer threads to perform potentially expensive deallocation/cleanup outside of the main loop, preventing deadline misses etc. This should make misbehaving `wait`s a bit more friendly.
- Loading branch information
1 parent
a0e905a
commit fe2282c
Showing
7 changed files
with
64 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
use super::message::*; | ||
use flume::Receiver; | ||
use tracing::instrument; | ||
|
||
/// The mixer's disposal thread is also synchronous, due to tracks, | ||
/// inputs, etc. being based on synchronous I/O. | ||
/// | ||
/// The mixer uses this to offload heavy and expensive drop operations | ||
/// to prevent deadline misses. | ||
#[instrument(skip(mix_rx))] | ||
pub(crate) fn runner(mix_rx: Receiver<DisposalMessage>) { | ||
loop { | ||
match mix_rx.recv() { | ||
Err(_) | Ok(DisposalMessage::Poison) => break, | ||
_ => {}, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#![allow(missing_docs)] | ||
|
||
use crate::tracks::Track; | ||
|
||
pub enum DisposalMessage { | ||
Track(Track), | ||
|
||
Poison, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
#![allow(missing_docs)] | ||
|
||
pub(crate) mod disposal; | ||
pub mod error; | ||
mod events; | ||
pub mod message; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters