mod_shell_stream: fix file_open() blocking playback until child exits - #3104
Open
RameshJayamJ wants to merge 1 commit into
Open
mod_shell_stream: fix file_open() blocking playback until child exits#3104RameshJayamJ wants to merge 1 commit into
RameshJayamJ wants to merge 1 commit into
Conversation
Removes the blocking wait() call in file_open() that prevented FreeSWITCH from calling file_read() until the entire external command had exited, defeating the purpose of the background buffering thread. Child process reaping moved to file_close() instead, with a bounded grace period + SIGKILL fallback. Fixes signalwire#3089 Signed-off-by: Ramesh Jayam J <ramesh.jayam@karix.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Removes the blocking
wait()call infile_open()that prevented FreeSWITCH from callingfile_read()until the entire external command had exited, defeating the purpose of the background buffering thread. Child process reaping is moved tofile_close()instead, with a bounded grace period +SIGKILLfallback so playback being cut short (e.g. caller hangs up mid-stream) can't leave a zombie or hung process.Before: audio from a streaming shell command (e.g. a script that generates and writes audio progressively, such as a real-time TTS engine) is completely silent until the script fully exits, then plays back all at once.
After: audio starts playing as soon as the first frame's worth of data is available in the buffer, and streams in naturally as the child process produces more.
Type of Change
Related Issues
Fixes #3089
Testing
Manually tested against a Python script streaming PCM16LE audio to stdout from a real-time TTS API over several seconds — confirmed playback now starts within the first buffered chunk instead of waiting for full completion. Also tested short-lived scripts (tone generator, static WAV file playback) to confirm unchanged behavior for that case, and tested closing the channel (hangup) while the child was still mid-stream to confirm clean process reaping via the grace-period/SIGKILL path.