Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ReadBuffer interface more robust #361

Merged
merged 1 commit into from
Sep 18, 2018
Merged

Make ReadBuffer interface more robust #361

merged 1 commit into from
Sep 18, 2018

Conversation

elprans
Copy link
Member

@elprans elprans commented Sep 13, 2018

The current ReadBuffer interface is somewhat error prone. There is no
way to "peek" at the next message, so various subprotocols that have
nested message processing loops have to resort to the _skip_discard
kludge on the protocol to inform the main loop that it shouldn't skip
over to the next message because the subprotocol already read too much.

Fix this by adding a way to iterate over the messages without
over-reading, and a way to "put" a message back into the buffer when
necessary. This also renames has_message() to take_message() to
make it clear that it changes the buffer state.

The current ReadBuffer interface is somewhat error prone.  There is no
way to "peek" at the next message, so various subprotocols that have
nested message processing loops have to resort to the `_skip_discard`
kludge on the protocol to inform the main loop that it shouldn't skip
over to the next message because the subprotocol already read too much.

Fix this by adding a way to iterate over the messages without
over-reading, and a way to "put" a message back into the buffer when
necessary.  This also renames `has_message()` to `take_message()` to
make it clear that it changes the buffer state.
@elprans elprans merged commit cc053fe into master Sep 18, 2018
@elprans elprans deleted the buffer branch September 18, 2018 13:43
@elprans elprans mentioned this pull request Sep 18, 2018
2 tasks
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.

None yet

2 participants