plugins, util: Prioritize stop events over processing#13107
Open
Dankirk wants to merge 1 commit intoobsproject:masterfrom
Open
plugins, util: Prioritize stop events over processing#13107Dankirk wants to merge 1 commit intoobsproject:masterfrom
Dankirk wants to merge 1 commit intoobsproject:masterfrom
Conversation
notr1ch
reviewed
Feb 10, 2026
c0a47a4 to
d5824ba
Compare
For WaitForMultipleObjects() the order of handles determines priority. Change stop events to be the first handle where appropriate to allow exiting when system is busy and multiple events are signaled at the same time. Adjustments for windows ipc-pipe stopping
d5824ba to
0be8736
Compare
Author
|
After taking a bit deeper dive into the current implementation of ipc pipe, I updated the way pipe-windows.c handles stop_event from the initial commit. Already updated the description, but here's the important bits:
|
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
For
WaitForMultipleObjects()the order of handles determines priority. This puts stop events as the first handle where appropriate to allow threads to exit when system is busy and multiple waited events are signaled at the same time.A potential problem with the re-prioritizing is that it might leave queued data unprocessed, so I added some handling where it could matter, but ignored the parts where it shouldn't.
Some additional changes for Windows ipc pipe (game capture):
ready_eventto be manual resetting as suggested for asynchronous ConnectPipe and OVERLAPPED struct in generalWaitFor*is followed byGetOverlappedResultwith waittrue. (Earlier this worked with auto only because for stopping we also callcancelIoExfrom outside the thread, which is not necessary anymore). The event is also reset byReadFiledespite being manual and restarting pipe re-creates the events.stop_eventis signaled orWaitForMultipleObjectsfails altogether, cancel current io and wait for completion inGetOverlappedResults, so that race conditions topipe->overlapand writes to to-be-freedbufcan be avoidded if pipe is restarted.For rtmp-windows.c I only added a robustness check for abandoned handles. It doesn't wait for its
stop_eventinsocket_thread_windows_internal()at all, but it instead should work throughsend_thread_signaled_exitevent regardless ofWaitForMultipleObjects()handle order, so I left it as it was.Motivation and Context
Noticed this being a potentially problematic pattern around the codebase when fixing a hang issue for captions. (#12729)
How Has This Been Tested?
Tested game capture (ipc pipe) that it works and closes itself properly, though extra eyes could be useful here.
Types of changes
Checklist: