diff options
author | michael-grunder <michael.grunder@gmail.com> | 2020-06-25 04:13:54 +0300 |
---|---|---|
committer | michael-grunder <michael.grunder@gmail.com> | 2020-06-25 04:13:54 +0300 |
commit | 857a2af49739beb6341350f881e2acf07a360499 (patch) | |
tree | 87d05c29a75689f6df4203961b65699af8289749 /library.c | |
parent | a311cc4ec3cecdbaf83ba66985efa82137e37cc0 (diff) |
Add liveness check and create pconnect "YOLO" mode.
Diffstat (limited to 'library.c')
-rw-r--r-- | library.c | 13 |
1 files changed, 13 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); |