Skip to content

Commit

Permalink
Merge branch 'feature/issue-323' of https://github.com/charsyam/twemp…
Browse files Browse the repository at this point in the history
…roxy into charsyam-feature/issue-323
  • Loading branch information
idning committed Apr 28, 2015
2 parents 8c8fd05 + 4d5ff8f commit 23da7de
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/proto/nc_redis.c
Original file line number Diff line number Diff line change
Expand Up @@ -1687,6 +1687,7 @@ redis_parse_rsp(struct msg *r)
SW_ERROR,
SW_INTEGER,
SW_INTEGER_START,
SW_SIMPLE,
SW_BULK,
SW_BULK_LF,
SW_BULK_ARG,
Expand Down Expand Up @@ -1773,6 +1774,13 @@ redis_parse_rsp(struct msg *r)
r->integer = 0;
break;

case SW_SIMPLE:
if (ch == CR) {
state = SW_MULTIBULK_ARGN_LF;
r->rnarg--;
}
break;

case SW_INTEGER_START:
if (ch == CR) {
state = SW_ALMOST_DONE;
Expand Down Expand Up @@ -1912,6 +1920,7 @@ redis_parse_rsp(struct msg *r)
/* response is '*0\r\n' */
goto done;
}

state = SW_MULTIBULK_ARGN_LEN;
break;

Expand Down Expand Up @@ -1953,9 +1962,17 @@ redis_parse_rsp(struct msg *r)
break;
}

if (ch != '$' && ch != ':') {
if (ch == ':' || ch == '+' || ch == '-') {
/* handles not-found reply = '$-1' or integer reply = ':<num>' */
/* and *2\r\n$2\r\nr0\r\n+OK\r\n or *1\r\n+OK\r\n */
state = SW_SIMPLE;
break;
}

if (ch != '$') {
goto error;
}

r->token = p;
r->rlen = 0;
} else if (isdigit(ch)) {
Expand All @@ -1967,8 +1984,7 @@ redis_parse_rsp(struct msg *r)
goto error;
}

if ((r->rlen == 1 && (p - r->token) == 3) || *r->token == ':') {
/* handles not-found reply = '$-1' or integer reply = ':<num>' */
if ((r->rlen == 1 && (p - r->token) == 3)) {
r->rlen = 0;
state = SW_MULTIBULK_ARGN_LF;
} else {
Expand Down

0 comments on commit 23da7de

Please sign in to comment.