diff options
author | Stephen Frost <sfrost@snowman.net> | 2013-08-01 15:42:07 -0400 |
---|---|---|
committer | Stephen Frost <sfrost@snowman.net> | 2013-08-01 15:42:07 -0400 |
commit | 8359ed806f3300b79f110f1ac216c58c0732d05c (patch) | |
tree | d18a033d0e7135088c758326e9b23c4a68f82bd6 /src/interfaces/libpq/fe-secure.c | |
parent | f31c149f13e4495051e014bab6fbe5e8ec4f56f1 (diff) | |
download | postgresql-8359ed806f3300b79f110f1ac216c58c0732d05c.tar.gz postgresql-8359ed806f3300b79f110f1ac216c58c0732d05c.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/interfaces/libpq/fe-secure.c')
-rw-r--r-- | src/interfaces/libpq/fe-secure.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/interfaces/libpq/fe-secure.c b/src/interfaces/libpq/fe-secure.c index e9a32ded154..b16968b049f 100644 --- a/src/interfaces/libpq/fe-secure.c +++ b/src/interfaces/libpq/fe-secure.c @@ -261,7 +261,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)) || @@ -1112,7 +1116,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) { @@ -1326,7 +1334,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) { |