Commit fe885c6e authored by Peter Eisentraut's avatar Peter Eisentraut

libpq: Report strerror on pthread_mutex_lock() failure

parent f1d5fce7
...@@ -256,14 +256,18 @@ pqsecure_open_client(PGconn *conn) ...@@ -256,14 +256,18 @@ pqsecure_open_client(PGconn *conn)
/* First time through? */ /* First time through? */
if (conn->ssl == NULL) if (conn->ssl == NULL)
{ {
#ifdef ENABLE_THREAD_SAFETY
int rc;
#endif
/* We cannot use MSG_NOSIGNAL to block SIGPIPE when using SSL */ /* We cannot use MSG_NOSIGNAL to block SIGPIPE when using SSL */
conn->sigpipe_flag = false; conn->sigpipe_flag = false;
#ifdef ENABLE_THREAD_SAFETY #ifdef ENABLE_THREAD_SAFETY
if (pthread_mutex_lock(&ssl_config_mutex)) if ((rc = pthread_mutex_lock(&ssl_config_mutex)))
{ {
printfPQExpBuffer(&conn->errorMessage, printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("unable to acquire mutex\n")); libpq_gettext("could not acquire mutex: %s\n"), strerror(rc));
return PGRES_POLLING_FAILED; return PGRES_POLLING_FAILED;
} }
#endif #endif
...@@ -1115,10 +1119,12 @@ initialize_SSL(PGconn *conn) ...@@ -1115,10 +1119,12 @@ initialize_SSL(PGconn *conn)
* SSL_context struct. * SSL_context struct.
*/ */
#ifdef ENABLE_THREAD_SAFETY #ifdef ENABLE_THREAD_SAFETY
if (pthread_mutex_lock(&ssl_config_mutex)) int rc;
if ((rc = pthread_mutex_lock(&ssl_config_mutex)))
{ {
printfPQExpBuffer(&conn->errorMessage, printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("unable to acquire mutex\n")); libpq_gettext("could not acquire mutex: %s\n"), strerror(rc));
return -1; return -1;
} }
#endif #endif
...@@ -1333,10 +1339,12 @@ initialize_SSL(PGconn *conn) ...@@ -1333,10 +1339,12 @@ initialize_SSL(PGconn *conn)
X509_STORE *cvstore; X509_STORE *cvstore;
#ifdef ENABLE_THREAD_SAFETY #ifdef ENABLE_THREAD_SAFETY
if (pthread_mutex_lock(&ssl_config_mutex)) int rc;
if ((rc = pthread_mutex_lock(&ssl_config_mutex)))
{ {
printfPQExpBuffer(&conn->errorMessage, printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("unable to acquire mutex\n")); libpq_gettext("could not acquire mutex: %s\n"), strerror(rc));
return -1; return -1;
} }
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment