From 45617385e72eb814c6548064835cf19cdf466a5b Mon Sep 17 00:00:00 2001 From: zhenwei pi Date: Mon, 22 Aug 2022 15:15:37 +0800 Subject: Use connection name of string Suggested by Oran, use an array to store all the connection types instead of a linked list, and use connection name of string. The index of a connection is dynamically allocated. Currently we support max 8 connection types, include: - tcp - unix socket - tls and RDMA is in the plan, then we have another 4 types to support, it should be enough in a long time. Introduce 3 functions to get connection type by a fast path: - connectionTypeTcp() - connectionTypeTls() - connectionTypeUnix() Note that connectionByType() is designed to use only in unlikely code path. Signed-off-by: zhenwei pi --- src/sentinel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/sentinel.c') diff --git a/src/sentinel.c b/src/sentinel.c index f0e3e8609..881f4b909 100644 --- a/src/sentinel.c +++ b/src/sentinel.c @@ -2376,8 +2376,8 @@ static int instanceLinkNegotiateTLS(redisAsyncContext *context) { #ifndef USE_OPENSSL (void) context; #else - SSL_CTX *redis_tls_ctx = connTypeGetCtx(CONN_TYPE_TLS); - SSL_CTX *redis_tls_client_ctx = connTypeGetClientCtx(CONN_TYPE_TLS); + SSL_CTX *redis_tls_ctx = connTypeGetCtx(connectionTypeTls()); + SSL_CTX *redis_tls_client_ctx = connTypeGetClientCtx(connectionTypeTls()); if (!redis_tls_ctx) return C_ERR; SSL *ssl = SSL_new(redis_tls_client_ctx ? redis_tls_client_ctx : redis_tls_ctx); -- cgit v1.2.1