diff options
-rw-r--r-- | library.c | 13 | ||||
-rw-r--r-- | redis.c | 1 |
2 files changed, 14 insertions, 0 deletions
@@ -2118,6 +2118,12 @@ static int redis_uniqid(char *buf, size_t buflen) { (long)tv.tv_sec, (long)tv.tv_usec, (long)php_rand()); } +static int redis_stream_liveness_check(php_stream *stream) { + return php_stream_set_option(stream, PHP_STREAM_OPTION_CHECK_LIVENESS, + 0, NULL) == PHP_STREAM_OPTION_RETURN_OK ? + SUCCESS : FAILURE; +} + static int redis_sock_check_liveness(RedisSock *redis_sock) { @@ -2125,6 +2131,13 @@ redis_sock_check_liveness(RedisSock *redis_sock) int idlen, auth; smart_string cmd = {0}; + /* Short circuit if we detect the stream has gone bad or if the user has + * configured persistent connection "YOLO mode". */ + if (redis_stream_liveness_check(redis_sock->stream) != SUCCESS) + return FAILURE; + else if (!INI_INT("redis.pconnect.echo_check_liveness")) + return SUCCESS; + /* AUTH (if we need it) */ auth = redis_sock_append_auth(redis_sock, &cmd); @@ -96,6 +96,7 @@ PHP_INI_BEGIN() /* redis pconnect */ PHP_INI_ENTRY("redis.pconnect.pooling_enabled", "1", PHP_INI_ALL, NULL) PHP_INI_ENTRY("redis.pconnect.connection_limit", "0", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("redis.pconnect.echo_check_liveness", "1", PHP_INI_ALL, NULL) PHP_INI_ENTRY("redis.pconnect.pool_pattern", "", PHP_INI_ALL, NULL) /* redis session */ |