mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-10 18:05:44 +02:00
fix: resp inline parsing correctly resets itself (#4458)
With empty inline string, the parser failed to continue parsing correctly the non-inline input. Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
parent
f6441df57a
commit
e89c15bc6a
2 changed files with 13 additions and 2 deletions
|
@ -232,8 +232,12 @@ auto RedisParser::ParseInline(Buffer str) -> ResultConsumed {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t last_consumed = ptr - str.data();
|
uint32_t last_consumed = ptr - str.data();
|
||||||
if (ptr == end) { // we have not finished parsing.
|
if (ptr == end) { // we have not finished parsing.
|
||||||
is_broken_token_ = ptr[-1] > 32; // we stopped in the middle of the token.
|
if (cached_expr_->empty()) {
|
||||||
|
state_ = CMD_COMPLETE_S; // have not found anything besides whitespace.
|
||||||
|
} else {
|
||||||
|
is_broken_token_ = ptr[-1] > 32; // we stopped in the middle of the token.
|
||||||
|
}
|
||||||
return {INPUT_PENDING, last_consumed};
|
return {INPUT_PENDING, last_consumed};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -281,4 +281,11 @@ TEST_F(RedisParserTest, InlineSplit) {
|
||||||
ASSERT_EQ(RedisParser::OK, Parse("ING\n"));
|
ASSERT_EQ(RedisParser::OK, Parse("ING\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(RedisParserTest, InlineReset) {
|
||||||
|
ASSERT_EQ(RedisParser::INPUT_PENDING, Parse("\t \r\n"));
|
||||||
|
EXPECT_EQ(4, consumed_);
|
||||||
|
ASSERT_EQ(RedisParser::OK, Parse("*1\r\n$3\r\nfoo\r\n"));
|
||||||
|
EXPECT_EQ(13, consumed_);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace facade
|
} // namespace facade
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue