Skip to content

Conversation

@vkmc
Copy link
Contributor

@vkmc vkmc commented Jan 7, 2026

The socket transport plugin used a fixed 64KB buffer size which caused messages surpassing that size to be truncated

For UDP/Unix datagram sockets, this resulted in parsing errors like "unexpected end of input"

This change allows the buffer to grow (up to a limit depending on the protocol) to accommodate larger messages.

Closes: OSPRH-23826

vkmc added 3 commits January 7, 2026 13:08
The socket transport plugin used a fixed 64KB buffer size
which caused messages surpassing that size to be truncated

For UDP/Unix datagram sockets, this resulted in parsing errors
like "unexpected end of input"

This change allows the buffer to grow (up to a limit depending on the
protocol) to accommodate larger messages.

Closes: OSPRH-23826
@vkmc
Copy link
Contributor Author

vkmc commented Jan 7, 2026

Still working on unit tests

@vkmc vkmc requested a review from vyzigold January 7, 2026 15:52
@vkmc vkmc removed the Do Not Merge label Jan 7, 2026
Copy link
Contributor

@vyzigold vyzigold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see one thing in the tests (see my comment) which needs a change / discussion. But otherwise this looks quite good. Thank you for the cleanup of the tests!

assert.Equal(t, true, len(receivedMsg) > 0)

// If we received a complete message, verify the content
if len(receivedMsg) == largeBuffSize+len(addition) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. Does it actually get inside this if? If I understand it correctly. You're sending a 128kb message, but the socket buffer hasn't expanded yet (it's still set to 64kb), so a truncated string is received and sent further (which means only the first half of the sent message gets assigned to receivedMsg right?). So this condition would be 64kb == 128kb + 19. So even though the test passes, I don't think the code inside the condition ever executes.

What I think should happen in this testcase:

  1. Send the large message + addition
  2. Optionally check that receivedMsg only has the first half of the message
  3. Send the same message again
  4. Check that we now have 128kb of data with the last character being '$'
  5. Send the same message again
  6. Check that we now have 128kb + 19 bytes of data and the end is "wubba lubba dub dub"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Indeed, we should extend this test to send a large message, catch the log message and verify we only received the base buffer size and then retry sending a long message and see it succeeds. I will fix this.

@vkmc
Copy link
Contributor Author

vkmc commented Jan 8, 2026

Thanks for the review!

This test verifies the dynamic buffer growth by sending
three messages

In each iteration the buffer grows from the initial size
of 65535 bytes to 3 times the initial size.

Also verifies the content of the received message
assert.Equal(t, true, len(receivedMsg) > 0)

// If we received a complete message, verify the content
if len(receivedMsg) == largeBuffSize+len(addition) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Indeed, we should extend this test to send a large message, catch the log message and verify we only received the base buffer size and then retry sending a long message and see it succeeds. I will fix this.

@vkmc vkmc requested a review from vyzigold January 13, 2026 11:05
@vkmc vkmc merged commit 03b182c into master Jan 13, 2026
21 checks passed
@vkmc vkmc deleted the OSPRH-23826/fix-long-messages-handling-grow-buffer branch January 13, 2026 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants