Skip to content

Commit

Permalink
IMHIREDIS::FIXED:: Restore compatiblity with hiredis < v1.0.0
Browse files Browse the repository at this point in the history
RESP3 protocol wasn't implemented yet, some types weren't available (REDIS_REPLY_DOUBLE)
  • Loading branch information
frikilax committed Jun 28, 2023
1 parent fa9ac84 commit b194bf3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion contrib/imhiredis/imhiredis.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,11 @@ static void redisAsyncRecvCallback (redisAsyncContext __attribute__((unused)) *c
static void redisAsyncConnectCallback (const redisAsyncContext *c, int status);
static void redisAsyncDisconnectCallback (const redisAsyncContext *c, int status);
static struct json_object* _redisParseIntegerReply(const redisReply *reply);
static struct json_object* _redisParseDoubleReply(const redisReply *reply);
static struct json_object* _redisParseStringReply(const redisReply *reply);
static struct json_object* _redisParseArrayReply(const redisReply *reply);
#ifdef REDIS_REPLY_DOUBLE
static struct json_object* _redisParseDoubleReply(const redisReply *reply);
#endif
static rsRetVal enqMsg(instanceConf_t *const inst, const char *message, size_t msgLen);
static rsRetVal enqMsgJson(instanceConf_t *const inst, struct json_object *json, struct json_object *metadata);
rsRetVal redisAuthentSynchronous(redisContext *conn, uchar *password);
Expand Down Expand Up @@ -898,9 +900,11 @@ static struct json_object* _redisParseIntegerReply(const redisReply *reply) {
return json_object_new_int64(reply->integer);
}

#ifdef REDIS_REPLY_DOUBLE
static struct json_object* _redisParseDoubleReply(const redisReply *reply) {
return json_object_new_double_s(reply->dval, reply->str);
}
#endif

static struct json_object* _redisParseStringReply(const redisReply *reply) {
return json_object_new_string_len(reply->str, reply->len);
Expand All @@ -923,10 +927,12 @@ static struct json_object* _redisParseArrayReply(const redisReply *reply) {
res = _redisParseIntegerReply(reply->element[i]);
json_object_object_add(result, key, res);
break;
#ifdef REDIS_REPLY_DOUBLE
case REDIS_REPLY_DOUBLE:
res = _redisParseDoubleReply(reply->element[i]);
json_object_object_add(result, key, res);
break;
#endif
case REDIS_REPLY_STRING:
res = _redisParseStringReply(reply->element[i]);
json_object_object_add(result, key, res);
Expand Down

0 comments on commit b194bf3

Please sign in to comment.