aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/libpq/fe-connect.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2021-06-29 11:31:08 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2021-06-29 11:31:08 -0400
commitaaddf6ba09e25878e792f0d15f725370e19396df (patch)
tree01803dc1ce8f2d85d2cc10126ae1e67689c2360c /src/interfaces/libpq/fe-connect.c
parent48cb244fb9aca1620e35a14617ca5869b3ea065a (diff)
downloadpostgresql-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-connect.c')
-rw-r--r--src/interfaces/libpq/fe-connect.c11
1 files changed, 8 insertions, 3 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
}