8000 libpq: Report strerror on pthread_mutex_lock() failure · hackingwu/postgres@a2e66c0 · GitHub
[go: up one dir, main page]

Skip to content

Commit a2e66c0

Browse files
committed
libpq: Report strerror on pthread_mutex_lock() failure
1 parent 6084c07 commit a2e66c0

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
@@ -257,14 +257,18 @@ pqsecure_open_client(PGconn *conn)
257257
/* First time through? */
258258
if (conn->ssl == NULL)
259259
{
260+
#ifdef ENABLE_THREAD_SAFETY
261+
int rc;
262+
#endif
263+
260264
/* We cannot use MSG_NOSIGNAL to block SIGPIPE when using SSL */
261265
conn->sigpipe_flag = false;
262266

263267
#ifdef ENABLE_THREAD_SAFETY
264-
if (pthread_mutex_lock(&ssl_config_mutex))
268+
if ((rc = pthread_mutex_lock(&ssl_config_mutex)))
265269
{
266270
printfPQExpBuffer(&conn->errorMessage,
267-
libpq_gettext("unable to acquire mutex\n"));
271+
libpq_gettext("could not acquire mutex: %s\n"), strerror(rc));
268272
return PGRES_POLLING_FAILED;
269273
}
270274
#endif
@@ -1114,10 +1118,12 @@ initialize_SSL(PGconn *conn)
11141118
* SSL_context struct.
11151119
*/
11161120
#ifdef ENABLE_THREAD_SAFETY
1117-
if (pthread_mutex_lock(&ssl_config_mutex))
1121+
int rc;
1122+
1123+
if ((rc = pthread_mutex_lock(&ssl_config_mutex)))
11181124
{
11191125
printfPQExpBuffer(&conn->errorMessage,
1120-
libpq_gettext("unable to acquire mutex\n"));
1126+
libpq_gettext("could not acquire mutex: %s\n"), strerror(rc));
11211127
return -1;
11221128
}
11231129
#endif
@@ -1332,10 +1338,12 @@ initialize_SSL(PGconn *conn)
13321338
X509_STORE *cvstore;
13331339

13341340
#ifdef ENABLE_THREAD_SAFETY
1335-
if (pthread_mutex_lock(&ssl_config_mutex))
1341+
int rc;
1342+
1343+
if ((rc = pthread_mutex_lock(&ssl_config_mutex)))
13361344
{
13371345
printfPQExpBuffer(&conn->errorMessage,
1338-
libpq_gettext("unable to acquire mutex\n"));
1346+
libpq_gettext("could not acquire mutex: %s\n"), strerror(rc));
13391347
return -1;
13401348
}
13411349
#endif

0 commit comments

Comments
 (0)
0