Skip to content

Commit

Permalink
WIP: Enable pooling for cluster slave nodes.
Browse files Browse the repository at this point in the history
Connections are stashed via redis_sock_disconnect so if RedisCluster
doesn't explicitly call that for slaves then pooling is never used for
those connections.

Addresses #1568
  • Loading branch information
michael-grunder committed Jun 15, 2019
1 parent 68c8382 commit 17600dd
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion cluster_library.c
Original file line number Diff line number Diff line change
Expand Up @@ -1256,11 +1256,19 @@ static int cluster_check_response(redisCluster *c, REDIS_REPLY_TYPE *reply_type

/* Disconnect from each node we're connected to */
PHP_REDIS_API void cluster_disconnect(redisCluster *c, int force TSRMLS_DC) {
redisClusterNode *node;
redisClusterNode *node, *slave;

ZEND_HASH_FOREACH_PTR(c->nodes, node) {
if (node == NULL) continue;

/* Disconnect from the master */
redis_sock_disconnect(node->sock, force TSRMLS_CC);

/* We also want to disconnect any slave connections so they will be pooled
* in the event we are using persistent connections and connection pooling. */
ZEND_HASH_FOREACH_PTR(node->slaves, slave) {
redis_sock_disconnect(slave->sock, force TSRMLS_CC);
} ZEND_HASH_FOREACH_END();
} ZEND_HASH_FOREACH_END();
}

Expand Down

0 comments on commit 17600dd

Please sign in to comment.