Fix hang while waiting for state changes. - #857
Open
aosmond wants to merge 1 commit into
Open
Conversation
In wait_for_state_change, it loops until the new state matches the desired state. Sometimes the state machine would skip the expected state to another. This would happen in aaudio_stream_start_locked, where we were in STARTING, expected to move to STARTED, and then it would transition into STOPPING/STOPPED/DISCONNECTED instead. This will cause the thread to block forever. This patch replaces wait_for_state_change into two new methods, with the existing callers updated appropriately: wait_for_stable_state, which doesn't verify what state we expect to move into, but simply until we leave the transitional state to a stable state. refresh_state, which updates the internal state and reports it without blocking.
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.
In wait_for_state_change, it loops until the new state matches the desired state. Sometimes the state machine would skip the expected state to another. This would happen in aaudio_stream_start_locked, where we were in STARTING, expected to move to STARTED, and then it would transition into STOPPING/STOPPED/DISCONNECTED instead. This will cause the thread to block forever.
This patch replaces wait_for_state_change into two new methods, with the existing callers updated appropriately:
wait_for_stable_state, which doesn't verify what state we expect to move into, but simply until we leave the transitional state to a stable state.
refresh_state, which updates the internal state and reports it without blocking.
--
This should fix bug 1831033, where the MediaDecoderStateMachine was hung waiting on a response from the remoted cubeb forever. It fixes a slew of intermittent failures for test_autoplay_* variants under dom/media/autoplay/test/mochitest.