diff options
author | michael-grunder <michael.grunder@gmail.com> | 2015-03-04 18:52:33 +0300 |
---|---|---|
committer | michael-grunder <michael.grunder@gmail.com> | 2015-05-06 01:16:50 +0300 |
commit | a70ba7f2e9b85db48309eac9f459c4713814e275 (patch) | |
tree | e4c655158a8199e206e17c495365e0c0966debeb | |
parent | 54a521e2271641dd429c09ef3678e77ae4ab9bc2 (diff) |
Multi-bulk serialization fixes
* Push our 'flag' socket's serialization settings into the multti-bulk
reply loop processing mechanism.
* Reset our serialization variable to NULL per loop iteration to fix
a memory leak.
-rw-r--r-- | cluster_library.c | 29 | ||||
-rw-r--r-- | redis_cluster.c | 17 |
2 files changed, 25 insertions, 21 deletions
diff --git a/cluster_library.c b/cluster_library.c index b49afc72..414a56e5 100644 --- a/cluster_library.c +++ b/cluster_library.c @@ -1381,7 +1381,6 @@ PHPAPI void cluster_bulk_resp(INTERNAL_FUNCTION_PARAMETERS, redisCluster *c, void *ctx) { char *resp; - zval *z_ret = NULL; // Make sure we can read the response if(c->reply_type != TYPE_BULK || @@ -1390,6 +1389,25 @@ PHPAPI void cluster_bulk_resp(INTERNAL_FUNCTION_PARAMETERS, redisCluster *c, CLUSTER_RETURN_FALSE(c); } + if (CLUSTER_IS_ATOMIC(c)) { + if (redis_unserialize(c->flags, resp, c->reply_len, &return_value + TSRMLS_CC) == 0) + { + CLUSTER_RETURN_STRING(c, resp, c->reply_len); + } else { + efree(resp); + } + } else { + zval *z = NULL; + if (redis_unserialize(c->flags, resp, c->reply_len, &z TSRMLS_CC)) { + efree(resp); + add_next_index_zval(c->multi_resp, z); + } else { + add_next_index_stringl(c->multi_resp, resp, c->reply_len, 0); + } + } + + /* // Return the string if we can unserialize it if(redis_unserialize(c->flags, resp, c->reply_len, &z_ret TSRMLS_CC)==0) { CLUSTER_RETURN_STRING(c, resp, c->reply_len); @@ -1400,7 +1418,7 @@ PHPAPI void cluster_bulk_resp(INTERNAL_FUNCTION_PARAMETERS, redisCluster *c, add_next_index_zval(c->multi_resp, z_ret); } efree(resp); - } + }*/ } /* Bulk response where we expect a double */ @@ -1796,6 +1814,9 @@ PHPAPI void cluster_gen_mbulk_resp(INTERNAL_FUNCTION_PARAMETERS, /* Consume replies as long as there are more than zero */ if (c->reply_len > 0) { + /* Push serialization settings from the cluster into our socket */ + c->cmd_sock->serializer = c->flags->serializer; + /* Call our specified callback */ if (cb(c->cmd_sock, z_result, c->reply_len, ctx TSRMLS_CC)==FAILURE) { zval_dtor(z_result); @@ -2168,7 +2189,6 @@ int mbulk_resp_loop(RedisSock *redis_sock, zval *z_result, { char *line; int line_len; - zval *z; // Iterate over the lines we have to process while(count--) { @@ -2177,6 +2197,7 @@ int mbulk_resp_loop(RedisSock *redis_sock, zval *z_result, if(line == NULL) return FAILURE; if(line_len > 0) { + zval *z = NULL; if(redis_unserialize(redis_sock, line, line_len, &z TSRMLS_CC)==1) { add_next_index_zval(z_result, z); efree(line); @@ -2199,7 +2220,7 @@ int mbulk_resp_loop_zipstr(RedisSock *redis_sock, zval *z_result, char *line, *key; int line_len, key_len; long long idx=0; - zval *z; + zval *z = NULL; // Our count wil need to be divisible by 2 if(count % 2 != 0) { diff --git a/redis_cluster.c b/redis_cluster.c index e23f4c27..6d54f64b 100644 --- a/redis_cluster.c +++ b/redis_cluster.c @@ -1092,23 +1092,6 @@ PHP_METHOD(RedisCluster, srandmember) { CLUSTER_ENQUEUE_RESPONSE(c, slot, cb, ctx); RETURN_ZVAL(getThis(), 1, 0); } - -/* - * cb = withscores ? cluster_mbulk_zipdbl_resp : cluster_mbulk_resp; - if (CLUSTER_IS_ATOMIC(c)) { - cb(INTERNAL_FUNCTION_PARAM_PASSTHRU, c, NULL); - } else { - void *ctx = NULL; - CLUSTER_ENQUEUE_RESPONSE(c, slot, cb, ctx); - RETURN_ZVAL(getThis(), 1, 0); - }*/ - - // Response type differs if we use WITHSCORES or not -/* if(have_count) { - cluster_mbulk_resp(INTERNAL_FUNCTION_PARAM_PASSTHRU, c, NULL); - } else { - cluster_bulk_resp(INTERNAL_FUNCTION_PARAM_PASSTHRU, c, NULL); - }*/ } /* {{{ proto string RedisCluster::strlen(string key) */ |