diff options
author | michael-grunder <michael.grunder@gmail.com> | 2022-10-13 05:38:38 +0300 |
---|---|---|
committer | michael-grunder <michael.grunder@gmail.com> | 2022-10-13 06:16:51 +0300 |
commit | 82fd1f201f11a307dc7a79056d455a3d4cff1cae (patch) | |
tree | bd1f30eb22d62676cb5f31d0a77f0998ea733e5e | |
parent | e392dd88dd89780633da3dd9ea6fb33dd187ff05 (diff) |
Better unix:// or file:// detection.issue.1836-unix-scheme
Fixes #1836
-rw-r--r-- | redis.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -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; } |