Skip to content

Commit

Permalink
Add an inexpensive liveness check and make challenge/response optional
Browse files Browse the repository at this point in the history
See #1742 and countless other persistent connection issues.
  • Loading branch information
michael-grunder committed May 1, 2020
1 parent 80f2529 commit 56898f8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions library.c
Original file line number Diff line number Diff line change
Expand Up @@ -1808,6 +1808,13 @@ redis_sock_check_liveness(RedisSock *redis_sock)
struct timeval tv;
size_t len;

/* Check socket liveness using 0 second timeout */
if (php_stream_set_option(redis_sock->stream, PHP_STREAM_OPTION_CHECK_LIVENESS, 0, NULL) != PHP_STREAM_OPTION_RETURN_OK) {
return FAILURE;
} else if (!INI_INT("redis.pconnect.echo_check_liveness")) {
return SUCCESS;
}

if (redis_sock->auth) {
redis_cmd_init_sstr(&cmd, 1, "AUTH", sizeof("AUTH") - 1);
redis_cmd_append_sstr(&cmd, ZSTR_VAL(redis_sock->auth), ZSTR_LEN(redis_sock->auth));
Expand Down
1 change: 1 addition & 0 deletions redis.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,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)

/* redis session */
PHP_INI_ENTRY("redis.session.locking_enabled", "0", PHP_INI_ALL, NULL)
Expand Down

0 comments on commit 56898f8

Please sign in to comment.