aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStephen Frost <sfrost@snowman.net>2013-08-01 15:42:07 -0400
committerStephen Frost <sfrost@snowman.net>2013-08-01 15:43:46 -0400
commit71127756af12ed64da9e82639f88b6ed13e5f600 (patch)
tree7f9ac57a2cfbc9ffa034e32b33034369a479edd9 /src
parent0b821b8d7c137fbec215f8da286b4a40e53b13d5 (diff)
downloadpostgresql-71127756af12ed64da9e82639f88b6ed13e5f600.tar.gz
postgresql-71127756af12ed64da9e82639f88b6ed13e5f600.zip
Improve handling of pthread_mutex_lock error case
We should really be reporting a useful error along with returning a valid return code if pthread_mutex_lock() throws an error for some reason. Add that and back-patch to 9.0 as the prior patch. Pointed out by Alvaro Herrera
Diffstat (limited to 'src')
-rw-r--r--src/interfaces/libpq/fe-secure.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/interfaces/libpq/fe-secure.c b/src/interfaces/libpq/fe-secure.c
index e607006bd1f..0176bd7ef7e 100644
--- a/src/interfaces/libpq/fe-secure.c
+++ b/src/interfaces/libpq/fe-secure.c
@@ -262,7 +262,11 @@ pqsecure_open_client(PGconn *conn)
#ifdef ENABLE_THREAD_SAFETY
if (pthread_mutex_lock(&ssl_config_mutex))
- return -1;
+ {
+ printfPQExpBuffer(&conn->errorMessage,
+ libpq_gettext("unable to acquire mutex\n"));
+ return PGRES_POLLING_FAILED;
+ }
#endif
/* Create a connection-specific SSL object */
if (!(conn->ssl = SSL_new(SSL_context)) ||
@@ -1111,7 +1115,11 @@ initialize_SSL(PGconn *conn)
*/
#ifdef ENABLE_THREAD_SAFETY
if (pthread_mutex_lock(&ssl_config_mutex))
+ {
+ printfPQExpBuffer(&conn->errorMessage,
+ libpq_gettext("unable to acquire mutex\n"));
return -1;
+ }
#endif
if (SSL_CTX_use_certificate_chain_file(SSL_context, fnbuf) != 1)
{
@@ -1325,7 +1333,11 @@ initialize_SSL(PGconn *conn)
#ifdef ENABLE_THREAD_SAFETY
if (pthread_mutex_lock(&ssl_config_mutex))
+ {
+ printfPQExpBuffer(&conn->errorMessage,
+ libpq_gettext("unable to acquire mutex\n"));
return -1;
+ }
#endif
if (SSL_CTX_load_verify_locations(SSL_context, fnbuf, NULL) != 1)
{