mirror of
https://github.com/postgres/postgres.git
synced 2025-07-08 11:42:09 +03:00
Remove --disable-thread-safety and related code.
All supported computers have either POSIX or Windows threads, and we no longer have any automated testing of --disable-thread-safety. We define a vestigial ENABLE_THREAD_SAFETY macro to 1 in ecpg_config.h in case it is useful, but we no longer test it anywhere in PostgreSQL code, and associated dead code paths are removed. The Meson and perl-based Windows build scripts never had an equivalent build option. Reviewed-by: Andres Freund <andres@anarazel.de> Reviewed-by: Peter Eisentraut <peter@eisentraut.org> Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi> Discussion: https://postgr.es/m/CA%2BhUKGLtmexrpMtxBRLCVePqV_dtWG-ZsEbyPrYc%2BNBB2TkNsw%40mail.gmail.com
This commit is contained in:
@ -55,42 +55,11 @@ static struct sqlca_t sqlca_init =
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef ENABLE_THREAD_SAFETY
|
||||
static pthread_key_t sqlca_key;
|
||||
static pthread_once_t sqlca_key_once = PTHREAD_ONCE_INIT;
|
||||
#else
|
||||
static struct sqlca_t sqlca =
|
||||
{
|
||||
{
|
||||
'S', 'Q', 'L', 'C', 'A', ' ', ' ', ' '
|
||||
},
|
||||
sizeof(struct sqlca_t),
|
||||
0,
|
||||
{
|
||||
0,
|
||||
{
|
||||
0
|
||||
}
|
||||
},
|
||||
{
|
||||
'N', 'O', 'T', ' ', 'S', 'E', 'T', ' '
|
||||
},
|
||||
{
|
||||
0, 0, 0, 0, 0, 0
|
||||
},
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
},
|
||||
{
|
||||
'0', '0', '0', '0', '0'
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_THREAD_SAFETY
|
||||
static pthread_mutex_t debug_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pthread_mutex_t debug_init_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
#endif
|
||||
static int simple_debug = 0;
|
||||
static FILE *debugstream = NULL;
|
||||
|
||||
@ -123,7 +92,6 @@ ecpg_init(const struct connection *con, const char *connection_name, const int l
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_THREAD_SAFETY
|
||||
static void
|
||||
ecpg_sqlca_key_destructor(void *arg)
|
||||
{
|
||||
@ -135,12 +103,10 @@ ecpg_sqlca_key_init(void)
|
||||
{
|
||||
pthread_key_create(&sqlca_key, ecpg_sqlca_key_destructor);
|
||||
}
|
||||
#endif
|
||||
|
||||
struct sqlca_t *
|
||||
ECPGget_sqlca(void)
|
||||
{
|
||||
#ifdef ENABLE_THREAD_SAFETY
|
||||
struct sqlca_t *sqlca;
|
||||
|
||||
pthread_once(&sqlca_key_once, ecpg_sqlca_key_init);
|
||||
@ -155,9 +121,6 @@ ECPGget_sqlca(void)
|
||||
pthread_setspecific(sqlca_key, sqlca);
|
||||
}
|
||||
return sqlca;
|
||||
#else
|
||||
return &sqlca;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
@ -240,9 +203,7 @@ ECPGtrans(int lineno, const char *connection_name, const char *transaction)
|
||||
void
|
||||
ECPGdebug(int n, FILE *dbgs)
|
||||
{
|
||||
#ifdef ENABLE_THREAD_SAFETY
|
||||
pthread_mutex_lock(&debug_init_mutex);
|
||||
#endif
|
||||
|
||||
if (n > 100)
|
||||
{
|
||||
@ -256,9 +217,7 @@ ECPGdebug(int n, FILE *dbgs)
|
||||
|
||||
ecpg_log("ECPGdebug: set to %d\n", simple_debug);
|
||||
|
||||
#ifdef ENABLE_THREAD_SAFETY
|
||||
pthread_mutex_unlock(&debug_init_mutex);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
@ -290,9 +249,7 @@ ecpg_log(const char *format,...)
|
||||
else
|
||||
snprintf(fmt, bufsize, "[%d]: %s", (int) getpid(), intl_format);
|
||||
|
||||
#ifdef ENABLE_THREAD_SAFETY
|
||||
pthread_mutex_lock(&debug_mutex);
|
||||
#endif
|
||||
|
||||
va_start(ap, format);
|
||||
vfprintf(debugstream, fmt, ap);
|
||||
@ -307,9 +264,7 @@ ecpg_log(const char *format,...)
|
||||
|
||||
fflush(debugstream);
|
||||
|
||||
#ifdef ENABLE_THREAD_SAFETY
|
||||
pthread_mutex_unlock(&debug_mutex);
|
||||
#endif
|
||||
|
||||
free(fmt);
|
||||
}
|
||||
@ -451,7 +406,6 @@ ECPGis_noind_null(enum ECPGttype type, const void *ptr)
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef ENABLE_THREAD_SAFETY
|
||||
|
||||
void
|
||||
win32_pthread_mutex(volatile pthread_mutex_t *mutex)
|
||||
@ -482,7 +436,6 @@ win32_pthread_once(volatile pthread_once_t *once, void (*fn) (void))
|
||||
pthread_mutex_unlock(&win32_pthread_once_lock);
|
||||
}
|
||||
}
|
||||
#endif /* ENABLE_THREAD_SAFETY */
|
||||
#endif /* WIN32 */
|
||||
|
||||
#ifdef ENABLE_NLS
|
||||
|
Reference in New Issue
Block a user