erlang-redis icon indicating copy to clipboard operation
erlang-redis copied to clipboard

Correctly return remaining data after parsing RESP array

Open climvalencia opened this issue 10 years ago • 0 comments

I found a bug in the redis_reply:data/1 parser.

If the redis server should return a reply array followed by any data (PONG in the example below), the redis_reply parser will incorrectly include PONG in the list of values, then finally return with a pending status.

1> redis_reply:data(<<"*2\r\n$4\r\nmem2\r\n$4\r\nmem1\r\n+PONG\r\n">>, {unknown, <<>>}).
{pending,{multi,2,
                ["PONG",<<"mem1">>,<<"mem2">>],
                {unknown,<<>>}}}

This results in redis_client (the calling process) ending up with a broken state that never sends back the replies.

Applying this fix should return the correct values:

1> redis_reply:data(<<"*2\r\n$4\r\nmem2\r\n$4\r\nmem1\r\n+PONG\r\n">>, {unknown, <<>>}).
{{value,{ok,[<<"mem2">>,<<"mem1">>]}},
 {unknown,<<"+PONG\r\n">>}}

climvalencia avatar Nov 07 '14 08:11 climvalencia