From: Peter Eisentraut Date: Sun, 18 Aug 2013 01:46:32 +0000 (-0400) Subject: libpq: Report strerror on pthread_mutex_lock() failure X-Git-Tag: REL9_4_BETA1~1212 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fe885c6e36667f2fbbf98d1f2f9657ee32acb1c1;p=postgresql libpq: Report strerror on pthread_mutex_lock() failure --- diff --git a/src/interfaces/libpq/fe-secure.c b/src/interfaces/libpq/fe-secure.c index b16968b049..3bd01131c6 100644 --- a/src/interfaces/libpq/fe-secure.c +++ b/src/interfaces/libpq/fe-secure.c @@ -256,14 +256,18 @@ pqsecure_open_client(PGconn *conn) /* First time through? */ if (conn->ssl == NULL) { +#ifdef ENABLE_THREAD_SAFETY + int rc; +#endif + /* We cannot use MSG_NOSIGNAL to block SIGPIPE when using SSL */ conn->sigpipe_flag = false; #ifdef ENABLE_THREAD_SAFETY - if (pthread_mutex_lock(&ssl_config_mutex)) + if ((rc = pthread_mutex_lock(&ssl_config_mutex))) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("unable to acquire mutex\n")); + libpq_gettext("could not acquire mutex: %s\n"), strerror(rc)); return PGRES_POLLING_FAILED; } #endif @@ -1115,10 +1119,12 @@ initialize_SSL(PGconn *conn) * SSL_context struct. */ #ifdef ENABLE_THREAD_SAFETY - if (pthread_mutex_lock(&ssl_config_mutex)) + int rc; + + if ((rc = pthread_mutex_lock(&ssl_config_mutex))) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("unable to acquire mutex\n")); + libpq_gettext("could not acquire mutex: %s\n"), strerror(rc)); return -1; } #endif @@ -1333,10 +1339,12 @@ initialize_SSL(PGconn *conn) X509_STORE *cvstore; #ifdef ENABLE_THREAD_SAFETY - if (pthread_mutex_lock(&ssl_config_mutex)) + int rc; + + if ((rc = pthread_mutex_lock(&ssl_config_mutex))) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("unable to acquire mutex\n")); + libpq_gettext("could not acquire mutex: %s\n"), strerror(rc)); return -1; } #endif