Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpredis/phpredis.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormichael-grunder <michael.grunder@gmail.com>2016-06-02 21:12:40 +0300
committermichael-grunder <michael.grunder@gmail.com>2016-06-02 21:12:40 +0300
commitfd5819c5206dc88de29a79455affaae645bb6d49 (patch)
tree313da19a6ea2c90539d3d5c0c1cc471aefc7cdea /cluster_library.c
parent254319ddb84f19d7296f3e92b3b9c665853189c5 (diff)
parent2a4407f7d93881e70381c3311be0968c059f73d2 (diff)
Merge branch 'php7-ipv6' into php7
Diffstat (limited to 'cluster_library.c')
-rw-r--r--cluster_library.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/cluster_library.c b/cluster_library.c
index 38e4827a..b7b299a8 100644
--- a/cluster_library.c
+++ b/cluster_library.c
@@ -846,8 +846,9 @@ cluster_init_seeds(redisCluster *cluster, HashTable *ht_seeds) {
// Grab a copy of the string
str = Z_STRVAL_P(z_seed);
- // Must be in host:port form
- if(!(psep = strchr(str, ':')))
+ /* Make sure we have a colon for host:port. Search right to left in the
+ * case of IPv6 */
+ if ((psep = strrchr(str, ':')) == NULL)
continue;
// Allocate a structure for this seed
@@ -922,12 +923,12 @@ static int cluster_set_redirection(redisCluster* c, char *msg, int moved)
/* Move past "MOVED" or "ASK */
msg += moved ? MOVED_LEN : ASK_LEN;
- // We need a slot seperator
- if(!(host = strchr(msg, ' '))) return -1;
+ /* Make sure we can find host */
+ if ((host = strchr(msg, ' ')) == NULL) return -1;
*host++ = '\0';
- // We need a : that seperates host from port
- if(!(port = strchr(host,':'))) return -1;
+ /* Find port, searching right to left in case of IPv6 */
+ if ((port = strrchr(host, ':')) == NULL) return -1;
*port++ = '\0';
// Success, apply it