Skip to content

Commit fe885c6

Browse files
committed
libpq: Report strerror on pthread_mutex_lock() failure
1 parent f1d5fce commit fe885c6

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/interfaces/libpq/fe-secure.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,14 +256,18 @@ pqsecure_open_client(PGconn *conn)
256256
/* First time through? */
257257
if (conn->ssl == NULL)
258258
{
259+
#ifdef ENABLE_THREAD_SAFETY
260+
int rc;
261+
#endif
262+
259263
/* We cannot use MSG_NOSIGNAL to block SIGPIPE when using SSL */
260264
conn->sigpipe_flag = false;
261265

262266
#ifdef ENABLE_THREAD_SAFETY
263-
if (pthread_mutex_lock(&ssl_config_mutex))
267+
if ((rc = pthread_mutex_lock(&ssl_config_mutex)))
264268
{
265269
printfPQExpBuffer(&conn->errorMessage,
266-
libpq_gettext("unable to acquire mutex\n"));
270+
libpq_gettext("could not acquire mutex: %s\n"), strerror(rc));
267271
return PGRES_POLLING_FAILED;
268272
}
269273
#endif
@@ -1115,10 +1119,12 @@ initialize_SSL(PGconn *conn)
11151119
* SSL_context struct.
11161120
*/
11171121
#ifdef ENABLE_THREAD_SAFETY
1118-
if (pthread_mutex_lock(&ssl_config_mutex))
1122+
int rc;
1123+
1124+
if ((rc = pthread_mutex_lock(&ssl_config_mutex)))
11191125
{
11201126
printfPQExpBuffer(&conn->errorMessage,
1121-
libpq_gettext("unable to acquire mutex\n"));
1127+
libpq_gettext("could not acquire mutex: %s\n"), strerror(rc));
11221128
return -1;
11231129
}
11241130
#endif
@@ -1333,10 +1339,12 @@ initialize_SSL(PGconn *conn)
13331339
X509_STORE *cvstore;
13341340

13351341
#ifdef ENABLE_THREAD_SAFETY
1336-
if (pthread_mutex_lock(&ssl_config_mutex))
1342+
int rc;
1343+
1344+
if ((rc = pthread_mutex_lock(&ssl_config_mutex)))
13371345
{
13381346
printfPQExpBuffer(&conn->errorMessage,
1339-
libpq_gettext("unable to acquire mutex\n"));
1347+
libpq_gettext("could not acquire mutex: %s\n"), strerror(rc));
13401348
return -1;
13411349
}
13421350
#endif

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy