mirror of
https://github.com/php-win-ext/phpredis.git
synced 2026-03-24 00:52:16 +01:00
Rewowrk CLUSTER_FREE_QUEUE as a static function
This commit is contained in:
committed by
Michael Grunder
parent
fae89fa992
commit
b004051499
@@ -64,6 +64,19 @@ cluster_enqueue_response(redisCluster *c, short slot, cluster_cb cb, void *ctx)
|
||||
}
|
||||
}
|
||||
|
||||
static void cluster_free_queue(redisCluster *c) {
|
||||
clusterFoldItem *item = c->multi_head, *tmp;
|
||||
|
||||
while (item) {
|
||||
tmp = item->next;
|
||||
efree(item);
|
||||
item = tmp;
|
||||
}
|
||||
|
||||
c->multi_head = NULL;
|
||||
c->multi_curr = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
cluster_process_cmd(INTERNAL_FUNCTION_PARAMETERS, redisCluster *c,
|
||||
redis_cmd_cb cmd_cb, cluster_cb resp_cb, int readonly)
|
||||
@@ -2187,7 +2200,7 @@ PHP_METHOD(RedisCluster, exec) {
|
||||
CLUSTER_THROW_EXCEPTION("Error processing EXEC across the cluster", 0);
|
||||
|
||||
// Free our queue, reset MULTI state
|
||||
CLUSTER_FREE_QUEUE(c);
|
||||
cluster_free_queue(c);
|
||||
CLUSTER_RESET_MULTI(c);
|
||||
|
||||
RETURN_FALSE;
|
||||
@@ -2203,7 +2216,7 @@ PHP_METHOD(RedisCluster, exec) {
|
||||
|
||||
// Free our callback queue, any enqueued distributed command context items
|
||||
// and reset our MULTI state.
|
||||
CLUSTER_FREE_QUEUE(c);
|
||||
cluster_free_queue(c);
|
||||
CLUSTER_RESET_MULTI(c);
|
||||
}
|
||||
|
||||
@@ -2220,7 +2233,7 @@ PHP_METHOD(RedisCluster, discard) {
|
||||
CLUSTER_RESET_MULTI(c);
|
||||
}
|
||||
|
||||
CLUSTER_FREE_QUEUE(c);
|
||||
cluster_free_queue(c);
|
||||
|
||||
RETURN_TRUE;
|
||||
}
|
||||
|
||||
@@ -9,16 +9,6 @@
|
||||
/* Get attached object context */
|
||||
#define GET_CONTEXT() PHPREDIS_ZVAL_GET_OBJECT(redisCluster, getThis())
|
||||
|
||||
/* Simple macro to free our enqueued callbacks after we EXEC */
|
||||
#define CLUSTER_FREE_QUEUE(c) \
|
||||
clusterFoldItem *_item = c->multi_head, *_tmp; \
|
||||
while(_item) { \
|
||||
_tmp = _item->next; \
|
||||
efree(_item); \
|
||||
_item = _tmp; \
|
||||
} \
|
||||
c->multi_head = c->multi_curr = NULL; \
|
||||
|
||||
/* Reset anything flagged as MULTI */
|
||||
#define CLUSTER_RESET_MULTI(c) \
|
||||
redisClusterNode *_node; \
|
||||
|
||||
Reference in New Issue
Block a user