diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2021-06-29 11:31:08 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2021-06-29 11:31:08 -0400 |
commit | aaddf6ba09e25878e792f0d15f725370e19396df (patch) | |
tree | 01803dc1ce8f2d85d2cc10126ae1e67689c2360c /src/interfaces/libpq/fe-secure-openssl.c | |
parent | 48cb244fb9aca1620e35a14617ca5869b3ea065a (diff) | |
download | postgresql-aaddf6ba09e25878e792f0d15f725370e19396df.tar.gz postgresql-aaddf6ba09e25878e792f0d15f725370e19396df.zip |
Remove libpq's use of abort(3) to handle mutex failure cases.
Doing an abort() seems all right in development builds, but not in
production builds of general-purpose libraries. However, the functions
that were doing this lack any way to report a failure back up to their
callers. It seems like we can just get away with ignoring failures in
production builds, since (a) no such failures have been reported in the
dozen years that the code's been like this, and (b) failure to enforce
mutual exclusion during fe-auth.c operations would likely not cause any
problems anyway in most cases. (The OpenSSL callbacks that use this
macro are obsolete, so even less likely to cause interesting problems.)
Possibly a better answer would be to break compatibility of the
pgthreadlock_t callback API, but in the absence of field problem
reports, it doesn't really seem worth the trouble.
Discussion: https://postgr.es/m/3131385.1624746109@sss.pgh.pa.us
Diffstat (limited to 'src/interfaces/libpq/fe-secure-openssl.c')
-rw-r--r-- | src/interfaces/libpq/fe-secure-openssl.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/interfaces/libpq/fe-secure-openssl.c b/src/interfaces/libpq/fe-secure-openssl.c index 67feaedc4e0..2ee5a0a40aa 100644 --- a/src/interfaces/libpq/fe-secure-openssl.c +++ b/src/interfaces/libpq/fe-secure-openssl.c @@ -611,15 +611,20 @@ static pthread_mutex_t *pq_lockarray; static void pq_lockingcallback(int mode, int n, const char *file, int line) { + /* + * There's no way to report a mutex-primitive failure, so we just Assert + * in development builds, and ignore any errors otherwise. Fortunately + * this is all obsolete in modern OpenSSL. + */ if (mode & CRYPTO_LOCK) { if (pthread_mutex_lock(&pq_lockarray[n])) - PGTHREAD_ERROR("failed to lock mutex"); + Assert(false); } else { if (pthread_mutex_unlock(&pq_lockarray[n])) - PGTHREAD_ERROR("failed to unlock mutex"); + Assert(false); } } #endif /* ENABLE_THREAD_SAFETY && HAVE_CRYPTO_LOCK */ |