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:
authorPavlo Yatsukhnenko <yatsukhnenko@users.noreply.github.com>2020-07-07 23:18:01 +0300
committerGitHub <noreply@github.com>2020-07-07 23:18:01 +0300
commitf771ea16b77f39fcca555bec2d952412265197aa (patch)
tree7b8828252f9a4d0b851286d96364ba94fccd6234 /library.c
parentbee44fb6c8549b65d036c3e62f96cebd5fd05e08 (diff)
Issue #1607 (#1806)
Diffstat (limited to 'library.c')
-rw-r--r--library.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/library.c b/library.c
index 2f95aea7..5ae25ef8 100644
--- a/library.c
+++ b/library.c
@@ -2165,9 +2165,9 @@ PHP_REDIS_API int redis_sock_connect(RedisSock *redis_sock)
{
struct timeval tv, read_tv, *tv_ptr = NULL;
zend_string *persistent_id = NULL, *estr = NULL;
- char host[1024], *pos, *address, *schema = NULL;
+ char host[1024], *pos, *address, *scheme = NULL;
const char *fmtstr = "%s://%s:%d";
- int host_len, usocket = 0, err = 0, tcp_flag = 1;
+ int host_len, usocket = 0, err = 0, tcp_flag = 1, scheme_free = 0;
ConnectionPool *p = NULL;
if (redis_sock->stream != NULL) {
@@ -2175,9 +2175,12 @@ PHP_REDIS_API int redis_sock_connect(RedisSock *redis_sock)
}
address = ZSTR_VAL(redis_sock->host);
- if ((pos = strstr(address, "://")) != NULL) {
- schema = estrndup(address, pos - address);
+ if ((pos = strstr(address, "://")) == NULL) {
+ scheme = redis_sock->stream_ctx ? "ssl" : "tcp";
+ } else {
+ scheme = estrndup(address, pos - address);
address = pos + sizeof("://") - 1;
+ scheme_free = 1;
}
if (address[0] == '/' && redis_sock->port < 1) {
host_len = snprintf(host, sizeof(host), "unix://%s", address);
@@ -2193,9 +2196,9 @@ PHP_REDIS_API int redis_sock_connect(RedisSock *redis_sock)
fmtstr = "%s://[%s]:%d";
}
#endif
- host_len = snprintf(host, sizeof(host), fmtstr, schema ? schema : "tcp", address, redis_sock->port);
- if (schema) efree(schema);
+ host_len = snprintf(host, sizeof(host), fmtstr, scheme, address, redis_sock->port);
}
+ if (scheme_free) efree(scheme);
if (redis_sock->persistent) {
if (INI_INT("redis.pconnect.pooling_enabled")) {