mirror of
https://github.com/phpredis/phpredis.git
synced 2026-06-19 07:35:31 +00:00
Rework CLUSTER_RESET_MULTI to be a static function
This commit is contained in:
committed by
Michael Grunder
parent
b004051499
commit
c3a7163108
+16
-3
@@ -77,6 +77,19 @@ static void cluster_free_queue(redisCluster *c) {
|
|||||||
c->multi_curr = NULL;
|
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
|
void
|
||||||
cluster_process_cmd(INTERNAL_FUNCTION_PARAMETERS, redisCluster *c,
|
cluster_process_cmd(INTERNAL_FUNCTION_PARAMETERS, redisCluster *c,
|
||||||
redis_cmd_cb cmd_cb, cluster_cb resp_cb, int readonly)
|
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
|
// Free our queue, reset MULTI state
|
||||||
cluster_free_queue(c);
|
cluster_free_queue(c);
|
||||||
CLUSTER_RESET_MULTI(c);
|
cluster_reset_multi(c);
|
||||||
|
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
@@ -2217,7 +2230,7 @@ PHP_METHOD(RedisCluster, exec) {
|
|||||||
// Free our callback queue, any enqueued distributed command context items
|
// Free our callback queue, any enqueued distributed command context items
|
||||||
// and reset our MULTI state.
|
// and reset our MULTI state.
|
||||||
cluster_free_queue(c);
|
cluster_free_queue(c);
|
||||||
CLUSTER_RESET_MULTI(c);
|
cluster_reset_multi(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* {{{ proto bool RedisCluster::discard() */
|
/* {{{ proto bool RedisCluster::discard() */
|
||||||
@@ -2230,7 +2243,7 @@ PHP_METHOD(RedisCluster, discard) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cluster_abort_exec(c) < 0) {
|
if (cluster_abort_exec(c) < 0) {
|
||||||
CLUSTER_RESET_MULTI(c);
|
cluster_reset_multi(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
cluster_free_queue(c);
|
cluster_free_queue(c);
|
||||||
|
|||||||
@@ -9,17 +9,6 @@
|
|||||||
/* Get attached object context */
|
/* Get attached object context */
|
||||||
#define GET_CONTEXT() PHPREDIS_ZVAL_GET_OBJECT(redisCluster, getThis())
|
#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,
|
void cluster_process_cmd(INTERNAL_FUNCTION_PARAMETERS, redisCluster *c,
|
||||||
redis_cmd_cb cmd_cb, cluster_cb resp_cb, int readonly);
|
redis_cmd_cb cmd_cb, cluster_cb resp_cb, int readonly);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user