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:
-rw-r--r--library.c13
-rw-r--r--redis.c1
2 files changed, 14 insertions, 0 deletions
diff --git a/library.c b/library.c
index 209cd1d0..7bf273a3 100644
--- a/library.c
+++ b/library.c
@@ -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);
diff --git a/redis.c b/redis.c
index b361aab2..ad681752 100644
--- a/redis.c
+++ b/redis.c
@@ -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 */