aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/interfaces/libpq/fe-connect.c11
-rw-r--r--src/interfaces/libpq/fe-secure-openssl.c9
-rw-r--r--src/interfaces/libpq/libpq-int.h7
3 files changed, 15 insertions, 12 deletions
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index 3faf05a7e71..fc65e490ef8 100644
--- a/src/interfaces/libpq/fe-connect.c
+++ b/src/interfaces/libpq/fe-connect.c
@@ -7254,6 +7254,11 @@ pqGetHomeDirectory(char *buf, int bufsize)
/*
* To keep the API consistent, the locking stubs are always provided, even
* if they are not required.
+ *
+ * Since we neglected to provide any error-return convention in the
+ * pgthreadlock_t API, we can't do much except Assert upon failure of any
+ * mutex primitive. Fortunately, such failures appear to be nonexistent in
+ * the field.
*/
static void
@@ -7273,7 +7278,7 @@ default_threadlock(int acquire)
if (singlethread_lock == NULL)
{
if (pthread_mutex_init(&singlethread_lock, NULL))
- PGTHREAD_ERROR("failed to initialize mutex");
+ Assert(false);
}
InterlockedExchange(&mutex_initlock, 0);
}
@@ -7281,12 +7286,12 @@ default_threadlock(int acquire)
if (acquire)
{
if (pthread_mutex_lock(&singlethread_lock))
- PGTHREAD_ERROR("failed to lock mutex");
+ Assert(false);
}
else
{
if (pthread_mutex_unlock(&singlethread_lock))
- PGTHREAD_ERROR("failed to unlock mutex");
+ Assert(false);
}
#endif
}
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 */
diff --git a/src/interfaces/libpq/libpq-int.h b/src/interfaces/libpq/libpq-int.h
index e81dc37906b..6b7fd2c267a 100644
--- a/src/interfaces/libpq/libpq-int.h
+++ b/src/interfaces/libpq/libpq-int.h
@@ -626,13 +626,6 @@ extern bool pqGetHomeDirectory(char *buf, int bufsize);
#ifdef ENABLE_THREAD_SAFETY
extern pgthreadlock_t pg_g_threadlock;
-#define PGTHREAD_ERROR(msg) \
- do { \
- fprintf(stderr, "%s\n", msg); \
- abort(); \
- } while (0)
-
-
#define pglock_thread() pg_g_threadlock(true)
#define pgunlock_thread() pg_g_threadlock(false)
#else