Added patch by Philip Yarra <philip.yarra@internode.on.net> for a bug in thread support.
This commit is contained in:
parent
7c13781ee7
commit
9dc2e6deaf
@ -1918,6 +1918,11 @@ Fri Mar 18 10:54:47 CET 2005
|
|||||||
|
|
||||||
- Added patch by Christof Petig <christof@petig-baender.de> to work
|
- Added patch by Christof Petig <christof@petig-baender.de> to work
|
||||||
around gcc bug on powerpc and amd64.
|
around gcc bug on powerpc and amd64.
|
||||||
|
|
||||||
|
Thu Apr 14 11:59:47 CEST 2005
|
||||||
|
|
||||||
|
- Added patch by Philip Yarra <philip.yarra@internode.on.net> for a
|
||||||
|
bug in thread support.
|
||||||
- Set ecpg library version to 5.1.
|
- Set ecpg library version to 5.1.
|
||||||
- Set ecpg version to 4.1.1.
|
- Set ecpg version to 4.1.1.
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.24 2004/12/30 09:36:37 meskes Exp $ */
|
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.25 2005/04/14 10:08:57 meskes Exp $ */
|
||||||
|
|
||||||
#define POSTGRES_ECPG_INTERNAL
|
#define POSTGRES_ECPG_INTERNAL
|
||||||
#include "postgres_fe.h"
|
#include "postgres_fe.h"
|
||||||
@ -17,9 +17,8 @@ static pthread_mutex_t connections_mutex = PTHREAD_MUTEX_INITIALIZER;
|
|||||||
static pthread_key_t actual_connection_key;
|
static pthread_key_t actual_connection_key;
|
||||||
static pthread_once_t actual_connection_key_once = PTHREAD_ONCE_INIT;
|
static pthread_once_t actual_connection_key_once = PTHREAD_ONCE_INIT;
|
||||||
|
|
||||||
#else
|
|
||||||
static struct connection *actual_connection = NULL;
|
|
||||||
#endif
|
#endif
|
||||||
|
static struct connection *actual_connection = NULL;
|
||||||
static struct connection *all_connections = NULL;
|
static struct connection *all_connections = NULL;
|
||||||
|
|
||||||
#ifdef ENABLE_THREAD_SAFETY
|
#ifdef ENABLE_THREAD_SAFETY
|
||||||
@ -39,6 +38,16 @@ ecpg_get_connection_nr(const char *connection_name)
|
|||||||
{
|
{
|
||||||
#ifdef ENABLE_THREAD_SAFETY
|
#ifdef ENABLE_THREAD_SAFETY
|
||||||
ret = pthread_getspecific(actual_connection_key);
|
ret = pthread_getspecific(actual_connection_key);
|
||||||
|
/* if no connection in TSD for this thread, get the global default connection
|
||||||
|
* and hope the user knows what they're doing (i.e. using their own mutex to
|
||||||
|
* protect that connection from concurrent accesses */
|
||||||
|
if(NULL == ret)
|
||||||
|
{
|
||||||
|
ECPGlog("no TSD connection, going for global\n");
|
||||||
|
ret = actual_connection;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ECPGlog("got the TSD connection\n");
|
||||||
#else
|
#else
|
||||||
ret = actual_connection;
|
ret = actual_connection;
|
||||||
#endif
|
#endif
|
||||||
@ -67,6 +76,16 @@ ECPGget_connection(const char *connection_name)
|
|||||||
{
|
{
|
||||||
#ifdef ENABLE_THREAD_SAFETY
|
#ifdef ENABLE_THREAD_SAFETY
|
||||||
ret = pthread_getspecific(actual_connection_key);
|
ret = pthread_getspecific(actual_connection_key);
|
||||||
|
/* if no connection in TSD for this thread, get the global default connection
|
||||||
|
* and hope the user knows what they're doing (i.e. using their own mutex to
|
||||||
|
* protect that connection from concurrent accesses */
|
||||||
|
if(NULL == ret)
|
||||||
|
{
|
||||||
|
ECPGlog("no TSD connection here either, using global\n");
|
||||||
|
ret = actual_connection;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ECPGlog("got TSD connection\n");
|
||||||
#else
|
#else
|
||||||
ret = actual_connection;
|
ret = actual_connection;
|
||||||
#endif
|
#endif
|
||||||
@ -117,10 +136,9 @@ ecpg_finish(struct connection * act)
|
|||||||
#ifdef ENABLE_THREAD_SAFETY
|
#ifdef ENABLE_THREAD_SAFETY
|
||||||
if (pthread_getspecific(actual_connection_key) == act)
|
if (pthread_getspecific(actual_connection_key) == act)
|
||||||
pthread_setspecific(actual_connection_key, all_connections);
|
pthread_setspecific(actual_connection_key, all_connections);
|
||||||
#else
|
#endif
|
||||||
if (actual_connection == act)
|
if (actual_connection == act)
|
||||||
actual_connection = all_connections;
|
actual_connection = all_connections;
|
||||||
#endif
|
|
||||||
|
|
||||||
ECPGlog("ecpg_finish: Connection %s closed.\n", act->name);
|
ECPGlog("ecpg_finish: Connection %s closed.\n", act->name);
|
||||||
|
|
||||||
@ -416,9 +434,8 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
|
|||||||
#ifdef ENABLE_THREAD_SAFETY
|
#ifdef ENABLE_THREAD_SAFETY
|
||||||
pthread_once(&actual_connection_key_once, ecpg_actual_connection_init);
|
pthread_once(&actual_connection_key_once, ecpg_actual_connection_init);
|
||||||
pthread_setspecific(actual_connection_key, all_connections);
|
pthread_setspecific(actual_connection_key, all_connections);
|
||||||
#else
|
|
||||||
actual_connection = all_connections;
|
|
||||||
#endif
|
#endif
|
||||||
|
actual_connection = all_connections;
|
||||||
|
|
||||||
ECPGlog("ECPGconnect: opening database %s on %s port %s %s%s%s%s\n",
|
ECPGlog("ECPGconnect: opening database %s on %s port %s %s%s%s%s\n",
|
||||||
realname ? realname : "<DEFAULT>",
|
realname ? realname : "<DEFAULT>",
|
||||||
|
Loading…
Reference in New Issue
Block a user