Fix incorrect behavior in message mode when too small buffer supplied#2809
Draft
ethouris wants to merge 38 commits intoHaivision:masterfrom
Draft
Fix incorrect behavior in message mode when too small buffer supplied#2809ethouris wants to merge 38 commits intoHaivision:masterfrom
ethouris wants to merge 38 commits intoHaivision:masterfrom
Conversation
Co-authored-by: stevomatthews <smatthews@haivision.com>
Co-authored-by: stevomatthews <smatthews@haivision.com>
Co-authored-by: stevomatthews <smatthews@haivision.com>
Collaborator
Author
|
I checked the documentation and the mention of SRT_ELARGEMSG under Possibly the current behavior should be maintained, but some possibility to extract a fragment of a message should be provided. My [FR] proposal:
The minimum set would be the implementation of the |
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.
The expected behavior in case when a too small buffer was supplied - according to the documentation - is that the message is not extracted and the call to the receiving function ends up with error code
SRT_ELARGEMSG.The current behavior is that if the buffer is too small, then a fragment of a message is extracted, as much as it fits in the buffer, and the rest of the mesage is abandoned. This doesn't make any sense at all, even though this resembles the behavior of UDP when a too small supplied buffer makes the packet completely extracted with only copied the possible fragment of the packet payload, although this is also reported by a flag.
Fragmentary reading should be possible, but only with some special, dedicated API. The default behavior should be as described in the documentation: if the buffer is too small to extract the message, then the operation ends up with error and the message is NOT extracted.
A special API could be also added (maybe a socket option, or using the flags field in SRT_MSGCTRL structure) that could allow extraction of a fragment of a message, while the rest remains in the buffer, and the application can call the receiving function again, to extract the rest of the message, possibly with a need to specify the message number (the same that was extracted by the previous call). If this was called with this flag set, then the returned value could be the total length of the message, and another appropriate flag should be set that says that the buffer has been filled up to the cork and the returned value is greater than its size. This requires some implementation effort to have an appropriate packet flag in the receiver buffer so that it is known how big part of the message was already extracted. The "notch" could be still reused the one used for stream mode.
CURRENTLY this is not a fix - it's only a test case that demonstrates the problem.
PREMATURELY MERGED: #2677 because this PR also modifies the tests for file transmission, so this is to avoid future merge problems.