Skip to content

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.

2 participants