Repository navigation
Fail loudly when a reply doesn't match its command - #18
Closed
henrikbjorn wants to merge 1 commit into
Closed
henrikbjorn wants to merge 1 commit into
henrikbjorn wants to merge 1 commit into
Conversation
FreeSWITCH answers each command on a connection once, in order, and its replies carry no request id, so librevox hands each reply to the oldest waiting command. Nothing checked that the reply was the kind that command expects. If commands and replies ever fell out of step, a caller could silently get someone else's reply. Each waiting command now records what it expects: an api/response for `api`, a command/reply for everything else. A reply of the other kind raises Librevox::ProtocolError (a ConnectionError) for every waiting command, and the connection is closed. A reply with no waiting command is dropped, as before. Two test fakes replied with the wrong kind, which FreeSWITCH never does. They now match real behaviour.
This was referenced Sep 30, 2026
Member
Author
|
Folded into #25, which collects these changes in one PR. |
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.
Stacked on #17.
FreeSWITCH answers each command on a connection once, in order, and its replies carry no request id, so librevox hands each reply to the oldest waiting command. Nothing checked that the reply was the kind that command expects. If commands and replies ever fell out of step, a caller could silently get someone else's reply.
What changes:
api/responseforapi, acommand/replyfor everything else.Librevox::ProtocolError(aConnectionError) for every waiting command, and the connection is closed.Together with Job-UUID (
bgapi), Application-UUID (app execution) and scoped variables (events an app causes), every response is either matched by id or checked against its command. None can be attributed to the wrong caller.Test fakes: two replied with the wrong kind, which FreeSWITCH never does, so they now match real behaviour:
base_test:api testnow gets anapi/response.outbound_apps_test: thesendmsgacknowledgement is fed before the unsolicitedapi/response.Tests:
bundle exec rake testgives 126 runs, including the newreply_matching_test.rb.