Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d05d301

Browse files
Better unix:// or file:// detection.
Fixes #1836
1 parent 5ac92d2 commit d05d301

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

redis.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,7 @@ redis_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
694694
size_t host_len, persistent_id_len;
695695
double timeout = 0.0, read_timeout = 0.0;
696696
redis_object *redis;
697+
int af_unix;
697698

698699
#ifdef ZTS
699700
/* not sure how in threaded mode this works so disabled persistence at
@@ -730,8 +731,13 @@ redis_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
730731
return FAILURE;
731732
}
732733

734+
/* Does the host look like a unix socket */
735+
af_unix = (host_len > 0 && host[0] == '/') ||
736+
(host_len > 6 && !strncasecmp(host, "unix://", sizeof("unix://") - 1)) ||
737+
(host_len > 6 && !strncasecmp(host, "file://", sizeof("file://") - 1));
738+
733739
/* If it's not a unix socket, set to default */
734-
if(port == -1 && host_len && host[0] != '/') {
740+
if (port == -1 && !af_unix) {
735741
port = 6379;
736742
}
737743

0 commit comments

Comments
 (0)