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

chore: parser cleanups #4076

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

chore: parser cleanups #4076

wants to merge 2 commits into from

Conversation

romange
Copy link
Collaborator

@romange romange commented Nov 6, 2024

Also, eliminate cases where we return INPUT_PENDING but do not consume the whole string. This should simplify buffer management for the caller, so that if they pass a string that did not result in complete parsed request, at least the whole string is consumed and can be discarded.

This PR handles only the ParseLen function that now stashes all the partial data if not enough data is provided.

@romange romange requested a review from kostasrim November 6, 2024 16:31
kostasrim
kostasrim previously approved these changes Nov 6, 2024
Copy link
Contributor

@kostasrim kostasrim left a comment

Choose a reason for hiding this comment

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

LGTM

InitStart(str[0], res);
}
DCHECK(state_ != CMD_COMPLETE_S);
Copy link
Contributor

Choose a reason for hiding this comment

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

I had to check this. InitStart does update state_ if it's equal CMD_COMPLETE_S so it's fine.

src/facade/redis_parser.cc Outdated Show resolved Hide resolved
if (pos[-1] != '\r') {
return BAD_INT;

consumed = pos - s + 1;
Copy link
Contributor

@kostasrim kostasrim Nov 6, 2024

Choose a reason for hiding this comment

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

I am blindly trusting you here. I haven;t checked the index calculations but the tests are failing and it's a sign that there is a mistake somewhere around here 😄

@kostasrim
Copy link
Contributor

Tests are failing :)

kostasrim
kostasrim previously approved these changes Nov 7, 2024
@romange romange force-pushed the Parser branch 9 times, most recently from dbf8419 to 6ce0516 Compare November 10, 2024 20:09
@romange romange force-pushed the Parser branch 4 times, most recently from e84c303 to b788c86 Compare November 29, 2024 09:03
@romange romange force-pushed the Parser branch 3 times, most recently from 63a3bf1 to f7fa90c Compare December 11, 2024 17:32
@kostasrim
Copy link
Contributor

@romange still not green

@romange
Copy link
Collaborator Author

romange commented Dec 12, 2024

And I still have not requested to review :)

@kostasrim
Copy link
Contributor

And I still have not requested to review :)

Uhhh I saw the notification and saw you asked 😄 nvm

@romange romange force-pushed the Parser branch 6 times, most recently from ae13a73 to 002d26d Compare December 18, 2024 07:57
1. Separate argument type parsing from argument parsing itself.
2. Handle strings of length 1.

This is done in preparation of improving the parser contract -
so that when it returns INPUT_PENDING, it consumes the entire input.

Signed-off-by: Roman Gershman <[email protected]>
This is needed in order to eliminate cases where we return INPUT_PENDING but do not consume the whole string by rejecting just several bytes.
This should simplify buffer management for the caller, so that if they pass a string that
did not result in complete parsed request, at least the whole string is consumed and can be discarded.

Signed-off-by: Roman Gershman <[email protected]>
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