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:
authormichael-grunder <michael.grunder@gmail.com>2020-06-25 04:13:54 +0300
committermichael-grunder <michael.grunder@gmail.com>2020-06-25 04:13:54 +0300
commit857a2af49739beb6341350f881e2acf07a360499 (patch)
tree87d05c29a75689f6df4203961b65699af8289749 /library.c
parenta311cc4ec3cecdbaf83ba66985efa82137e37cc0 (diff)
Add liveness check and create pconnect "YOLO" mode.
Diffstat (limited to 'library.c')
-rw-r--r--library.c13
1 files changed, 13 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);