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>2022-10-13 05:38:38 +0300
committermichael-grunder <michael.grunder@gmail.com>2022-10-13 06:16:51 +0300
commit82fd1f201f11a307dc7a79056d455a3d4cff1cae (patch)
treebd1f30eb22d62676cb5f31d0a77f0998ea733e5e
parente392dd88dd89780633da3dd9ea6fb33dd187ff05 (diff)
Better unix:// or file:// detection.issue.1836-unix-scheme
Fixes #1836
-rw-r--r--redis.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/redis.c b/redis.c
index f68227fd..3a3370bf 100644
--- a/redis.c
+++ b/redis.c
@@ -694,6 +694,7 @@ redis_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
size_t host_len, persistent_id_len;
double timeout = 0.0, read_timeout = 0.0;
redis_object *redis;
+ int af_unix;
#ifdef ZTS
/* not sure how in threaded mode this works so disabled persistence at
@@ -730,8 +731,13 @@ redis_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
return FAILURE;
}
+ /* Does the host look like a unix socket */
+ af_unix = (host_len > 0 && host[0] == '/') ||
+ (host_len > 6 && !strncasecmp(host, "unix://", sizeof("unix://") - 1)) ||
+ (host_len > 6 && !strncasecmp(host, "file://", sizeof("file://") - 1));
+
/* If it's not a unix socket, set to default */
- if(port == -1 && host_len && host[0] != '/') {
+ if (port == -1 && !af_unix) {
port = 6379;
}