mirror of
https://github.com/postgres/postgres.git
synced 2025-05-02 11:44:50 +03:00
Improve handling of pthread_mutex_lock error case
We should really be reporting a useful error along with returning a valid return code if pthread_mutex_lock() throws an error for some reason. Add that and back-patch to 9.0 as the prior patch. Pointed out by Alvaro Herrera
This commit is contained in:
parent
9d7f66bc6c
commit
1e8e324326
@ -262,7 +262,11 @@ pqsecure_open_client(PGconn *conn)
|
|||||||
|
|
||||||
#ifdef ENABLE_THREAD_SAFETY
|
#ifdef ENABLE_THREAD_SAFETY
|
||||||
if (pthread_mutex_lock(&ssl_config_mutex))
|
if (pthread_mutex_lock(&ssl_config_mutex))
|
||||||
return -1;
|
{
|
||||||
|
printfPQExpBuffer(&conn->errorMessage,
|
||||||
|
libpq_gettext("unable to acquire mutex\n"));
|
||||||
|
return PGRES_POLLING_FAILED;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
/* Create a connection-specific SSL object */
|
/* Create a connection-specific SSL object */
|
||||||
if (!(conn->ssl = SSL_new(SSL_context)) ||
|
if (!(conn->ssl = SSL_new(SSL_context)) ||
|
||||||
@ -1113,7 +1117,11 @@ initialize_SSL(PGconn *conn)
|
|||||||
*/
|
*/
|
||||||
#ifdef ENABLE_THREAD_SAFETY
|
#ifdef ENABLE_THREAD_SAFETY
|
||||||
if (pthread_mutex_lock(&ssl_config_mutex))
|
if (pthread_mutex_lock(&ssl_config_mutex))
|
||||||
|
{
|
||||||
|
printfPQExpBuffer(&conn->errorMessage,
|
||||||
|
libpq_gettext("unable to acquire mutex\n"));
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
if (SSL_CTX_use_certificate_chain_file(SSL_context, fnbuf) != 1)
|
if (SSL_CTX_use_certificate_chain_file(SSL_context, fnbuf) != 1)
|
||||||
{
|
{
|
||||||
@ -1327,7 +1335,11 @@ initialize_SSL(PGconn *conn)
|
|||||||
|
|
||||||
#ifdef ENABLE_THREAD_SAFETY
|
#ifdef ENABLE_THREAD_SAFETY
|
||||||
if (pthread_mutex_lock(&ssl_config_mutex))
|
if (pthread_mutex_lock(&ssl_config_mutex))
|
||||||
|
{
|
||||||
|
printfPQExpBuffer(&conn->errorMessage,
|
||||||
|
libpq_gettext("unable to acquire mutex\n"));
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
if (SSL_CTX_load_verify_locations(SSL_context, fnbuf, NULL) != 1)
|
if (SSL_CTX_load_verify_locations(SSL_context, fnbuf, NULL) != 1)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user