Unverified Commit 3761fdb0 authored by Ozan Tezcan's avatar Ozan Tezcan Committed by GitHub
Browse files

Use cached value correctly inside connectionTypeTls() (#11236)



When Redis is built without TLS support, connectionTypeTls() function 
keeps searching connection type as cached connection type is NULL. 

Added another variable to track if we cached the connection type to 
prevent search after the first time. 

Noticed a log warning message is printed repeatedly by connectionTypeTls.
Co-authored-by: default avatarzhenwei pi <pizhenwei@bytedance.com>
Co-authored-by: default avatarOran Agra <oran@redislabs.com>
parent e764e2a6
......@@ -103,11 +103,15 @@ ConnectionType *connectionTypeTcp() {
/* Cache TLS connection type, query it by string once */
ConnectionType *connectionTypeTls() {
static ConnectionType *ct_tls = NULL;
static int cached = 0;
if (ct_tls != NULL)
return ct_tls;
/* Unlike the TCP and Unix connections, the TLS one can be missing
* So we need the cached pointer to handle NULL correctly too. */
if (!cached) {
cached = 1;
ct_tls = connectionByType(CONN_TYPE_TLS);
}
ct_tls = connectionByType(CONN_TYPE_TLS);
return ct_tls;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment