From 8c91ac2b02ebd42350bb96c9a08ddb95b3a8e7d6 Mon Sep 17 00:00:00 2001 From: dormando Date: Wed, 31 Jul 2024 17:24:54 -0700 Subject: [PATCH] tls: fix disabled-tls compilation guess these snuck in after my last round of testing. --- memcached.c | 2 +- memcached.h | 4 ++-- tls.c | 2 ++ tls.h | 2 ++ 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/memcached.c b/memcached.c index ef16775e75..20ead54f08 100644 --- a/memcached.c +++ b/memcached.c @@ -906,7 +906,7 @@ static void conn_close(conn *c) { MEMCACHED_CONN_RELEASE(c->sfd); conn_set_state(c, conn_closed); - if (c->ssl) { + if (c->ssl_enabled) { ssl_conn_close(c->ssl); } close(c->sfd); diff --git a/memcached.h b/memcached.h index f77ea918b8..57fa5389f1 100644 --- a/memcached.h +++ b/memcached.h @@ -482,6 +482,7 @@ struct settings { bool lru_maintainer_thread; /* LRU maintainer background thread */ bool lru_segmented; /* Use split or flat LRU's */ bool slab_reassign; /* Whether or not slab reassignment is allowed */ + bool ssl_enabled; /* indicates whether SSL is enabled */ int slab_automove; /* Whether or not to automatically move slabs */ double slab_automove_ratio; /* youngest must be within pct of oldest */ unsigned int slab_automove_window; /* window mover for algorithm */ @@ -521,7 +522,6 @@ struct settings { double ext_max_frag; /* ideal maximum page fragmentation */ double slab_automove_freeratio; /* % of memory to hold free as buffer */ bool ext_drop_unread; /* skip unread items during compaction */ - bool ssl_enabled; /* indicates whether SSL is enabled */ /* start flushing to extstore after memory below this */ unsigned int ext_global_pool_min; #endif @@ -834,8 +834,8 @@ struct conn { bool close_after_write; /** flush write then move to close connection */ bool rbuf_malloced; /** read buffer was malloc'ed for ascii mget, needs free() */ bool item_malloced; /** item for conn_nread state is a temporary malloc */ -#ifdef TLS bool ssl_enabled; +#ifdef TLS void *ssl; char *ssl_wbuf; #endif diff --git a/tls.c b/tls.c index 7b888df3d6..1c9f3f657f 100644 --- a/tls.c +++ b/tls.c @@ -419,6 +419,8 @@ int ssl_init(void) { * SSL_OP_NO_RENEGOTIATION option in SSL_CTX_set_options. */ void ssl_callback(const SSL *s, int where, int ret) { + // useful for debugging. + // fprintf(stderr, "WHERE: %d RET: %d CODE: %s LONG: %s\n", where, ret, SSL_state_string(s), SSL_state_string_long(s)); #ifndef SSL_OP_NO_RENEGOTIATION SSL* ssl = (SSL*)s; if (SSL_in_before(ssl)) { diff --git a/tls.h b/tls.h index 4fb7e05c5c..86b0bb0b25 100644 --- a/tls.h +++ b/tls.h @@ -12,12 +12,14 @@ void ssl_help(void); bool ssl_set_verify_mode(int verify); bool ssl_set_min_version(int version); const char *ssl_proto_text(int version); +void ssl_help(void); #else #define ssl_init(void) #define ssl_init_conn(c, ssl) #define ssl_init_settings(void) #define ssl_conn_close(ssl) #define ssl_accept(c, sfd, fail) NULL +#define ssl_help() #endif #endif