Skip to content

Commit

Permalink
Fix xInfo ro RedisCluster
Browse files Browse the repository at this point in the history
  • Loading branch information
yatsukhnenko committed Jun 12, 2019
1 parent 4852a51 commit ac9dca0
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
18 changes: 18 additions & 0 deletions cluster_library.c
Original file line number Diff line number Diff line change
Expand Up @@ -2314,6 +2314,24 @@ cluster_xclaim_resp(INTERNAL_FUNCTION_PARAMETERS, redisCluster *c, void *ctx) {

}

/* XINFO */
PHP_REDIS_API void
cluster_xinfo_resp(INTERNAL_FUNCTION_PARAMETERS, redisCluster *c, void *ctx)
{
zval z_ret;

array_init(&z_ret);
if (redis_read_xinfo_response(c->cmd_sock, &z_ret, c->reply_len) != SUCCESS) {
zval_dtor(&z_ret);
CLUSTER_RETURN_FALSE(c);
}

if (CLUSTER_IS_ATOMIC(c)) {
RETURN_ZVAL(&z_ret, 0, 1);
}
add_next_index_zval(&c->multi_resp, &z_ret);
}

/* MULTI BULK response loop where we might pull the next one */
PHP_REDIS_API zval *cluster_zval_mbulk_resp(INTERNAL_FUNCTION_PARAMETERS,
redisCluster *c, int pull, mbulk_cb cb, zval *z_ret)
Expand Down
2 changes: 2 additions & 0 deletions cluster_library.h
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,8 @@ PHP_REDIS_API void cluster_xrange_resp(INTERNAL_FUNCTION_PARAMETERS,
redisCluster *c, void *ctx);
PHP_REDIS_API void cluster_xclaim_resp(INTERNAL_FUNCTION_PARAMETERS,
redisCluster *c, void *ctx);
PHP_REDIS_API void cluster_xinfo_resp(INTERNAL_FUNCTION_PARAMETERS,
redisCluster *c, void *ctx);

/* MULTI BULK processing callbacks */
int mbulk_resp_loop(RedisSock *redis_sock, zval *z_result,
Expand Down
2 changes: 1 addition & 1 deletion library.c
Original file line number Diff line number Diff line change
Expand Up @@ -1451,7 +1451,7 @@ redis_xclaim_reply(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
return -1;
}

static int
PHP_REDIS_API int
redis_read_xinfo_response(RedisSock *redis_sock, zval *z_ret, int elements)
{
zval zv;
Expand Down
2 changes: 2 additions & 0 deletions library.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ PHP_REDIS_API int
redis_read_stream_messages_multi(RedisSock *redis_sock, int count, zval *z_ret TSRMLS_DC);
PHP_REDIS_API int
redis_read_xclaim_response(RedisSock *redis_sock, int count, zval *rv TSRMLS_DC);
PHP_REDIS_API int
redis_read_xinfo_response(RedisSock *redis_sock, zval *z_ret, int elements TSRMLS_DC);

/*
* Variant Read methods, mostly to implement eval
Expand Down
2 changes: 1 addition & 1 deletion redis_cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -3095,7 +3095,7 @@ PHP_METHOD(RedisCluster, xgroup) {

/* {{{ proto variant RedisCluster::xinfo(string op, [string arg1, string arg2]); */
PHP_METHOD(RedisCluster, xinfo) {
CLUSTER_PROCESS_CMD(xinfo, cluster_variant_resp, 0);
CLUSTER_PROCESS_CMD(xinfo, cluster_xinfo_resp, 0);
}

/* {{{ proto string RedisCluster::xlen(string key) }}} */
Expand Down

0 comments on commit ac9dca0

Please sign in to comment.