Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

SISAutomationIMA
Copy link

Hello,

If there are several fragmented requests and only fragmented requests, the program crashes on reading.

I find out where the issue is.
In the _read_build_multi_requests method:

# TODO: this should try and combine these into the fewest packets
grouped_requests = [[]]
current_group = grouped_requests[0]
current_response_size = MULTISERVICE_READ_OVERHEAD
for req, resp_size in read_requests:
    if current_response_size + resp_size > self.connection_size:
        current_group = []
        grouped_requests.append(current_group)
        current_response_size = MULTISERVICE_READ_OVERHEAD

    current_group.append(req)
    current_response_size += resp_size

multi_requests = [
    MultiServiceRequestPacket(self._sequence, group) for group in grouped_requests
]

return multi_requests + fragmented_requests

This is because grouped_requests is added to multi_requests even if read_requests is empty. This created an MultiServiceRequestPacket with no tag and it crashes the program at the reading.

So I add a test to check if grouped_requests is empty. This is maybe not the best way to do it. This is more to show you the issue than a pull request.

Thank you.

Correct empty multi_requests for ReadFragmentedRequests
Copy link
Owner

@ottowayi ottowayi left a comment

Choose a reason for hiding this comment

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

Thanks for find this, I'm not too proud of this code and it's a bit of a mess so I appreciate finding and fixing bugs like this

@ottowayi ottowayi changed the base branch from master to develop November 12, 2021 15:02
@ottowayi ottowayi merged commit d4802be into ottowayi:develop Nov 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants