mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
The "cvs add" of test_thread_implicit.pgc seems to have been missed,
i've attached this again. Additionally I include a small patch to remove mutex locking when a DEFAULT/NULL connection is being retrieved. This is consistent with libpq. Lee Kindness
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.20 2004/03/14 12:16:29 meskes Exp $ */
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.21 2004/03/15 16:27:43 momjian Exp $ */
|
||||
|
||||
#define POSTGRES_ECPG_INTERNAL
|
||||
#include "postgres_fe.h"
|
||||
@ -62,18 +62,28 @@ ECPGget_connection(const char *connection_name)
|
||||
{
|
||||
struct connection *ret = NULL;
|
||||
|
||||
if ((connection_name == NULL) || (strcmp(connection_name, "CURRENT") == 0))
|
||||
{
|
||||
#ifdef ENABLE_THREAD_SAFETY
|
||||
pthread_mutex_lock(&connections_mutex);
|
||||
ret = pthread_getspecific(actual_connection_key);
|
||||
#else
|
||||
ret = actual_connection;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef ENABLE_THREAD_SAFETY
|
||||
pthread_mutex_lock(&connections_mutex);
|
||||
#endif
|
||||
|
||||
ret = ecpg_get_connection_nr(connection_name);
|
||||
ret = ecpg_get_connection_nr(connection_name);
|
||||
|
||||
#ifdef ENABLE_THREAD_SAFETY
|
||||
pthread_mutex_unlock(&connections_mutex);
|
||||
pthread_mutex_unlock(&connections_mutex);
|
||||
#endif
|
||||
}
|
||||
|
||||
return (ret);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
|
Reference in New Issue
Block a user