From c3a71631080d0e40a66b1362bc9113f4048a9aca Mon Sep 17 00:00:00 2001 From: michael-grunder Date: Thu, 14 Aug 2025 18:49:07 -0700 Subject: [PATCH] Rework `CLUSTER_RESET_MULTI` to be a static function --- redis_cluster.c | 19 ++++++++++++++++--- redis_cluster.h | 11 ----------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/redis_cluster.c b/redis_cluster.c index ea8a1291..0d4deda2 100644 --- a/redis_cluster.c +++ b/redis_cluster.c @@ -77,6 +77,19 @@ static void cluster_free_queue(redisCluster *c) { c->multi_curr = NULL; } +static void cluster_reset_multi(redisCluster *c) { + redisClusterNode *node; + ZEND_HASH_FOREACH_PTR(c->nodes, node) { + if (node == NULL) + break; + node->sock->watching = 0; + node->sock->mode = ATOMIC; + } ZEND_HASH_FOREACH_END(); + + c->flags->watching = 0; + c->flags->mode = ATOMIC; +} + void cluster_process_cmd(INTERNAL_FUNCTION_PARAMETERS, redisCluster *c, redis_cmd_cb cmd_cb, cluster_cb resp_cb, int readonly) @@ -2201,7 +2214,7 @@ PHP_METHOD(RedisCluster, exec) { // Free our queue, reset MULTI state cluster_free_queue(c); - CLUSTER_RESET_MULTI(c); + cluster_reset_multi(c); RETURN_FALSE; } @@ -2217,7 +2230,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_RESET_MULTI(c); + cluster_reset_multi(c); } /* {{{ proto bool RedisCluster::discard() */ @@ -2230,7 +2243,7 @@ PHP_METHOD(RedisCluster, discard) { } if (cluster_abort_exec(c) < 0) { - CLUSTER_RESET_MULTI(c); + cluster_reset_multi(c); } cluster_free_queue(c); diff --git a/redis_cluster.h b/redis_cluster.h index 4dc833b5..443d4160 100644 --- a/redis_cluster.h +++ b/redis_cluster.h @@ -9,17 +9,6 @@ /* Get attached object context */ #define GET_CONTEXT() PHPREDIS_ZVAL_GET_OBJECT(redisCluster, getThis()) -/* Reset anything flagged as MULTI */ -#define CLUSTER_RESET_MULTI(c) \ - redisClusterNode *_node; \ - ZEND_HASH_FOREACH_PTR(c->nodes, _node) { \ - if (_node == NULL) break; \ - _node->sock->watching = 0; \ - _node->sock->mode = ATOMIC; \ - } ZEND_HASH_FOREACH_END(); \ - c->flags->watching = 0; \ - c->flags->mode = ATOMIC; \ - void cluster_process_cmd(INTERNAL_FUNCTION_PARAMETERS, redisCluster *c, redis_cmd_cb cmd_cb, cluster_cb resp_cb, int readonly);