aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/libpq/fe-secure-openssl.c
diff options
context:
space:
mode:
authorThomas Munro <tmunro@postgresql.org>2023-07-12 06:20:37 +1200
committerThomas Munro <tmunro@postgresql.org>2023-07-12 08:20:43 +1200
commit68a4b58eca032916e2aad78d63f717dcb147e906 (patch)
treed944d9ffb794df9d70c6408475f20d20a0580080 /src/interfaces/libpq/fe-secure-openssl.c
parent11f36694091c97318e5a2bd28b35ffe9aa1c3b6a (diff)
downloadpostgresql-68a4b58eca032916e2aad78d63f717dcb147e906.tar.gz
postgresql-68a4b58eca032916e2aad78d63f717dcb147e906.zip
Remove --disable-thread-safety and related code.
All supported computers have either POSIX or Windows threads, and we no longer have any automated testing of --disable-thread-safety. We define a vestigial ENABLE_THREAD_SAFETY macro to 1 in ecpg_config.h in case it is useful, but we no longer test it anywhere in PostgreSQL code, and associated dead code paths are removed. The Meson and perl-based Windows build scripts never had an equivalent build option. Reviewed-by: Andres Freund <andres@anarazel.de> Reviewed-by: Peter Eisentraut <peter@eisentraut.org> Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi> Discussion: https://postgr.es/m/CA%2BhUKGLtmexrpMtxBRLCVePqV_dtWG-ZsEbyPrYc%2BNBB2TkNsw%40mail.gmail.com
Diffstat (limited to 'src/interfaces/libpq/fe-secure-openssl.c')
-rw-r--r--src/interfaces/libpq/fe-secure-openssl.c17
1 files changed, 3 insertions, 14 deletions
diff --git a/src/interfaces/libpq/fe-secure-openssl.c b/src/interfaces/libpq/fe-secure-openssl.c
index bea71660ab8..f1192d28f26 100644
--- a/src/interfaces/libpq/fe-secure-openssl.c
+++ b/src/interfaces/libpq/fe-secure-openssl.c
@@ -44,13 +44,11 @@
#include <sys/stat.h>
-#ifdef ENABLE_THREAD_SAFETY
#ifdef WIN32
#include "pthread-win32.h"
#else
#include <pthread.h>
#endif
-#endif
/*
* These SSL-related #includes must come after all system-provided headers.
@@ -91,7 +89,6 @@ static bool pq_init_crypto_lib = true;
static bool ssl_lib_initialized = false;
-#ifdef ENABLE_THREAD_SAFETY
static long crypto_open_connections = 0;
#ifndef WIN32
@@ -100,7 +97,6 @@ static pthread_mutex_t ssl_config_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t ssl_config_mutex = NULL;
static long win32_ssl_create_mutex = 0;
#endif
-#endif /* ENABLE_THREAD_SAFETY */
static PQsslKeyPassHook_OpenSSL_type PQsslKeyPassHook = NULL;
static int ssl_protocol_version_to_openssl(const char *protocol);
@@ -112,15 +108,12 @@ static int ssl_protocol_version_to_openssl(const char *protocol);
void
pgtls_init_library(bool do_ssl, int do_crypto)
{
-#ifdef ENABLE_THREAD_SAFETY
-
/*
* Disallow changing the flags while we have open connections, else we'd
* get completely confused.
*/
if (crypto_open_connections != 0)
return;
-#endif
pq_init_ssl_lib = do_ssl;
pq_init_crypto_lib = do_crypto;
@@ -718,7 +711,7 @@ pgtls_verify_peer_name_matches_certificate_guts(PGconn *conn,
return rc;
}
-#if defined(ENABLE_THREAD_SAFETY) && defined(HAVE_CRYPTO_LOCK)
+#if defined(HAVE_CRYPTO_LOCK)
/*
* Callback functions for OpenSSL internal locking. (OpenSSL 1.1.0
* does its own locking, and doesn't need these anymore. The
@@ -759,7 +752,7 @@ pq_lockingcallback(int mode, int n, const char *file, int line)
Assert(false);
}
}
-#endif /* ENABLE_THREAD_SAFETY && HAVE_CRYPTO_LOCK */
+#endif /* HAVE_CRYPTO_LOCK */
/*
* Initialize SSL library.
@@ -774,7 +767,6 @@ pq_lockingcallback(int mode, int n, const char *file, int line)
int
pgtls_init(PGconn *conn, bool do_ssl, bool do_crypto)
{
-#ifdef ENABLE_THREAD_SAFETY
#ifdef WIN32
/* Also see similar code in fe-connect.c, default_threadlock() */
if (ssl_config_mutex == NULL)
@@ -840,7 +832,6 @@ pgtls_init(PGconn *conn, bool do_ssl, bool do_crypto)
}
}
#endif /* HAVE_CRYPTO_LOCK */
-#endif /* ENABLE_THREAD_SAFETY */
if (!ssl_lib_initialized && do_ssl)
{
@@ -857,9 +848,7 @@ pgtls_init(PGconn *conn, bool do_ssl, bool do_crypto)
ssl_lib_initialized = true;
}
-#ifdef ENABLE_THREAD_SAFETY
pthread_mutex_unlock(&ssl_config_mutex);
-#endif
return 0;
}
@@ -878,7 +867,7 @@ pgtls_init(PGconn *conn, bool do_ssl, bool do_crypto)
static void
destroy_ssl_system(void)
{
-#if defined(ENABLE_THREAD_SAFETY) && defined(HAVE_CRYPTO_LOCK)
+#if defined(HAVE_CRYPTO_LOCK)
/* Mutex is created in pgtls_init() */
if (pthread_mutex_lock(&ssl_config_mutex))
return;