diff options
Diffstat (limited to 'src/interfaces/ecpg/ecpglib/connect.c')
-rw-r--r-- | src/interfaces/ecpg/ecpglib/connect.c | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/src/interfaces/ecpg/ecpglib/connect.c b/src/interfaces/ecpg/ecpglib/connect.c index db0bae1fe08..8afb1f0a26f 100644 --- a/src/interfaces/ecpg/ecpglib/connect.c +++ b/src/interfaces/ecpg/ecpglib/connect.c @@ -14,15 +14,12 @@ locale_t ecpg_clocale = (locale_t) 0; #endif -#ifdef ENABLE_THREAD_SAFETY static pthread_mutex_t connections_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_key_t actual_connection_key; static pthread_once_t actual_connection_key_once = PTHREAD_ONCE_INIT; -#endif static struct connection *actual_connection = NULL; static struct connection *all_connections = NULL; -#ifdef ENABLE_THREAD_SAFETY static void ecpg_actual_connection_init(void) { @@ -34,7 +31,6 @@ ecpg_pthreads_init(void) { pthread_once(&actual_connection_key_once, ecpg_actual_connection_init); } -#endif static struct connection * ecpg_get_connection_nr(const char *connection_name) @@ -43,7 +39,6 @@ ecpg_get_connection_nr(const char *connection_name) if ((connection_name == NULL) || (strcmp(connection_name, "CURRENT") == 0)) { -#ifdef ENABLE_THREAD_SAFETY ecpg_pthreads_init(); /* ensure actual_connection_key is valid */ ret = pthread_getspecific(actual_connection_key); @@ -56,9 +51,6 @@ ecpg_get_connection_nr(const char *connection_name) if (ret == NULL) /* no TSD connection, going for global */ ret = actual_connection; -#else - ret = actual_connection; -#endif } else { @@ -82,7 +74,6 @@ ecpg_get_connection(const char *connection_name) if ((connection_name == NULL) || (strcmp(connection_name, "CURRENT") == 0)) { -#ifdef ENABLE_THREAD_SAFETY ecpg_pthreads_init(); /* ensure actual_connection_key is valid */ ret = pthread_getspecific(actual_connection_key); @@ -95,21 +86,14 @@ ecpg_get_connection(const char *connection_name) if (ret == NULL) /* no TSD connection here either, using global */ ret = actual_connection; -#else - ret = actual_connection; -#endif } else { -#ifdef ENABLE_THREAD_SAFETY pthread_mutex_lock(&connections_mutex); -#endif ret = ecpg_get_connection_nr(connection_name); -#ifdef ENABLE_THREAD_SAFETY pthread_mutex_unlock(&connections_mutex); -#endif } return ret; @@ -143,10 +127,8 @@ ecpg_finish(struct connection *act) con->next = act->next; } -#ifdef ENABLE_THREAD_SAFETY if (pthread_getspecific(actual_connection_key) == act) pthread_setspecific(actual_connection_key, all_connections); -#endif if (actual_connection == act) actual_connection = all_connections; @@ -212,11 +194,7 @@ ECPGsetconn(int lineno, const char *connection_name) if (!ecpg_init(con, connection_name, lineno)) return false; -#ifdef ENABLE_THREAD_SAFETY pthread_setspecific(actual_connection_key, con); -#else - actual_connection = con; -#endif return true; } @@ -326,9 +304,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p if (dbname == NULL && connection_name == NULL) connection_name = "DEFAULT"; -#if ENABLE_THREAD_SAFETY ecpg_pthreads_init(); -#endif /* check if the identifier is unique */ if (ecpg_get_connection(connection_name)) @@ -505,9 +481,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p } /* add connection to our list */ -#ifdef ENABLE_THREAD_SAFETY pthread_mutex_lock(&connections_mutex); -#endif /* * ... but first, make certain we have created ecpg_clocale. Rely on @@ -519,9 +493,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p ecpg_clocale = newlocale(LC_NUMERIC_MASK, "C", (locale_t) 0); if (!ecpg_clocale) { -#ifdef ENABLE_THREAD_SAFETY pthread_mutex_unlock(&connections_mutex); -#endif ecpg_raise(lineno, ECPG_OUT_OF_MEMORY, ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY, NULL); if (host) @@ -558,9 +530,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p this->next = all_connections; all_connections = this; -#ifdef ENABLE_THREAD_SAFETY pthread_setspecific(actual_connection_key, all_connections); -#endif actual_connection = all_connections; ecpg_log("ECPGconnect: opening database %s on %s port %s %s%s %s%s\n", @@ -678,9 +648,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p ecpg_log("ECPGconnect: %s", errmsg); ecpg_finish(this); -#ifdef ENABLE_THREAD_SAFETY pthread_mutex_unlock(&connections_mutex); -#endif ecpg_raise(lineno, ECPG_CONNECT, ECPG_SQLSTATE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION, db); if (realname) @@ -692,9 +660,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p if (realname) ecpg_free(realname); -#ifdef ENABLE_THREAD_SAFETY pthread_mutex_unlock(&connections_mutex); -#endif this->autocommit = autocommit; @@ -716,9 +682,7 @@ ECPGdisconnect(int lineno, const char *connection_name) return false; } -#ifdef ENABLE_THREAD_SAFETY pthread_mutex_lock(&connections_mutex); -#endif if (strcmp(connection_name, "ALL") == 0) { @@ -737,18 +701,14 @@ ECPGdisconnect(int lineno, const char *connection_name) if (!ecpg_init(con, connection_name, lineno)) { -#ifdef ENABLE_THREAD_SAFETY pthread_mutex_unlock(&connections_mutex); -#endif return false; } else ecpg_finish(con); } -#ifdef ENABLE_THREAD_SAFETY pthread_mutex_unlock(&connections_mutex); -#endif return true; } |