Properly reset state after protocol error in reply reader
This commit is contained in:
parent
864bce944b
commit
663d6d1258
@ -493,7 +493,7 @@ static void redisSetReplyReaderError(redisReader *r, sds err) {
|
|||||||
if (r->buf != NULL) {
|
if (r->buf != NULL) {
|
||||||
sdsfree(r->buf);
|
sdsfree(r->buf);
|
||||||
r->buf = sdsempty();
|
r->buf = sdsempty();
|
||||||
r->pos = 0;
|
r->pos = r->len = 0;
|
||||||
}
|
}
|
||||||
r->ridx = -1;
|
r->ridx = -1;
|
||||||
r->error = err;
|
r->error = err;
|
||||||
|
9
test.c
9
test.c
@ -318,6 +318,15 @@ static void test_reply_reader(void) {
|
|||||||
ret = redisReplyReaderGetReply(reader,&reply);
|
ret = redisReplyReaderGetReply(reader,&reply);
|
||||||
test_cond(ret == REDIS_OK && reply == (void*)REDIS_REPLY_STATUS);
|
test_cond(ret == REDIS_OK && reply == (void*)REDIS_REPLY_STATUS);
|
||||||
redisReplyReaderFree(reader);
|
redisReplyReaderFree(reader);
|
||||||
|
|
||||||
|
test("Properly reset state after protocol error: ");
|
||||||
|
reader = redisReplyReaderCreate();
|
||||||
|
redisReplyReaderSetReplyObjectFunctions(reader,NULL);
|
||||||
|
redisReplyReaderFeed(reader,(char*)"x",1);
|
||||||
|
ret = redisReplyReaderGetReply(reader,&reply);
|
||||||
|
assert(ret == REDIS_ERR);
|
||||||
|
ret = redisReplyReaderGetReply(reader,&reply);
|
||||||
|
test_cond(ret == REDIS_OK && reply == NULL)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_throughput(void) {
|
static void test_throughput(void) {
|
||||||
|
Loading…
Reference in New Issue
Block a user