]> granicus.if.org Git - postgresql/commitdiff
libpq: Report strerror on pthread_mutex_lock() failure
authorPeter Eisentraut <peter_e@gmx.net>
Sun, 18 Aug 2013 01:46:32 +0000 (21:46 -0400)
committerPeter Eisentraut <peter_e@gmx.net>
Sun, 18 Aug 2013 01:52:24 +0000 (21:52 -0400)
src/interfaces/libpq/fe-secure.c

index ba063a09ce153adbe5115c3b1d3d6d72e12e49ad..2ff229c6833a0d0bff0e3853f0219c13c9e59d78 100644 (file)
@@ -257,14 +257,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
@@ -1116,10 +1120,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
@@ -1334,10 +1340,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