diff options
author | Yossi Gottlieb <yossigo@gmail.com> | 2019-08-04 11:55:24 +0300 |
---|---|---|
committer | Yossi Gottlieb <yossigo@gmail.com> | 2019-08-04 11:55:24 +0300 |
commit | a7a1886b7eaeac0265af419a3f9c0793e7098d46 (patch) | |
tree | 8fbb2bbf518d26b770d0390bebfcc042c9b047cb /read.c | |
parent | f5f855c91239706b173e2412cea301f4a3643e2d (diff) |
Initial RESP3 support [d5c54f0b].
Diffstat (limited to 'read.c')
-rw-r--r-- | read.c | 17 |
1 files changed, 14 insertions, 3 deletions
@@ -362,7 +362,8 @@ static int processBulkItem(redisReader *r) { return REDIS_ERR; } -static int processMultiBulkItem(redisReader *r) { +/* Process the array, map and set types. */ +static int processAggregateItem(redisReader *r) { redisReadTask *cur = &(r->rstack[r->ridx]); void *obj; char *p; @@ -404,10 +405,12 @@ static int processMultiBulkItem(redisReader *r) { moveToNextTask(r); } else { + if (cur->type == REDIS_REPLY_MAP) elements *= 2; + if (r->fn && r->fn->createArray) obj = r->fn->createArray(cur,elements); else - obj = (void*)REDIS_REPLY_ARRAY; + obj = (void*)(long)cur->type; if (obj == NULL) { __redisReaderSetErrorOOM(r); @@ -461,6 +464,12 @@ static int processItem(redisReader *r) { case '*': cur->type = REDIS_REPLY_ARRAY; break; + case '%': + cur->type = REDIS_REPLY_MAP; + break; + case '~': + cur->type = REDIS_REPLY_SET; + break; default: __redisReaderSetErrorProtocolByte(r,*p); return REDIS_ERR; @@ -480,7 +489,9 @@ static int processItem(redisReader *r) { case REDIS_REPLY_STRING: return processBulkItem(r); case REDIS_REPLY_ARRAY: - return processMultiBulkItem(r); + case REDIS_REPLY_MAP: + case REDIS_REPLY_SET: + return processAggregateItem(r); default: assert(NULL); return REDIS_ERR; /* Avoid warning. */ |