Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 68a4b58

Browse files
committed
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
1 parent 11f3669 commit 68a4b58

38 files changed

+137
-509
lines changed

configure

+5-49
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,6 @@ with_tcl
722722
ICU_LIBS
723723
ICU_CFLAGS
724724
with_icu
725-
enable_thread_safety
726725
INCLUDES
727726
autodepend
728727
PKG_CONFIG_LIBDIR
@@ -848,7 +847,6 @@ with_CC
848847
with_llvm
849848
enable_depend
850849
enable_cassert
851-
enable_thread_safety
852850
with_icu
853851
with_tcl
854852
with_tclconfig
@@ -1536,7 +1534,6 @@ Optional Features:
15361534
--enable-tap-tests enable TAP tests (requires Perl and IPC::Run)
15371535
--enable-depend turn on automatic dependency tracking
15381536
--enable-cassert enable assertion checks (for debugging)
1539-
--disable-thread-safety disable thread-safety in client libraries
15401537
--disable-largefile omit support for large files
15411538

15421539
Optional Packages:
@@ -8338,43 +8335,6 @@ $as_echo "$as_me: WARNING: *** Library directory $dir does not exist." >&2;}
83388335
done
83398336
IFS=$ac_save_IFS
83408337

8341-
#
8342-
# Enable thread-safe client libraries
8343-
#
8344-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking allow thread-safe client libraries" >&5
8345-
$as_echo_n "checking allow thread-safe client libraries... " >&6; }
8346-
8347-
8348-
# Check whether --enable-thread-safety was given.
8349-
if test "${enable_thread_safety+set}" = set; then :
8350-
enableval=$enable_thread_safety;
8351-
case $enableval in
8352-
yes)
8353-
:
8354-
;;
8355-
no)
8356-
:
8357-
;;
8358-
*)
8359-
as_fn_error $? "no argument expected for --enable-thread-safety option" "$LINENO" 5
8360-
;;
8361-
esac
8362-
8363-
else
8364-
enable_thread_safety=yes
8365-
8366-
fi
8367-
8368-
8369-
if test "$enable_thread_safety" = yes; then
8370-
8371-
$as_echo "#define ENABLE_THREAD_SAFETY 1" >>confdefs.h
8372-
8373-
fi
8374-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_thread_safety" >&5
8375-
$as_echo "$enable_thread_safety" >&6; }
8376-
8377-
83788338
#
83798339
# ICU
83808340
#
@@ -11064,7 +11024,7 @@ fi
1106411024
done
1106511025

1106611026

11067-
if test "$enable_thread_safety" = yes -a "$PORTNAME" != "win32"; then :
11027+
if test "$PORTNAME" != "win32"; then :
1106811028
# then
1106911029

1107011030

@@ -11723,7 +11683,7 @@ if test "x$ac_cv_header_pthread_h" = xyes; then :
1172311683

1172411684
else
1172511685
as_fn_error $? "
11726-
pthread.h not found; use --disable-thread-safety to disable thread safety" "$LINENO" 5
11686+
pthread.h not found" "$LINENO" 5
1172711687
fi
1172811688

1172911689

@@ -12407,8 +12367,7 @@ if test "$ac_res" != no; then :
1240712367
fi
1240812368

1240912369

12410-
if test "$enable_thread_safety" = yes; then
12411-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing pthread_barrier_wait" >&5
12370+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing pthread_barrier_wait" >&5
1241212371
$as_echo_n "checking for library containing pthread_barrier_wait... " >&6; }
1241312372
if ${ac_cv_search_pthread_barrier_wait+:} false; then :
1241412373
$as_echo_n "(cached) " >&6
@@ -12464,7 +12423,6 @@ if test "$ac_res" != no; then :
1246412423

1246512424
fi
1246612425

12467-
fi
1246812426

1246912427
if test "$with_readline" = yes; then
1247012428

@@ -13349,7 +13307,7 @@ else
1334913307
thread_safe_libldap=no
1335013308
fi
1335113309

13352-
if test "$enable_thread_safety" = yes -a "$thread_safe_libldap" = no; then
13310+
if test "$thread_safe_libldap" = no; then
1335313311
# Use ldap_r for FE if available, else assume ldap is thread-safe.
1335413312
# On some platforms ldap_r fails to link without PTHREAD_LIBS.
1335513313
LIBS="$_LIBS"
@@ -16377,8 +16335,7 @@ fi
1637716335

1637816336

1637916337

16380-
if test "$enable_thread_safety" = yes; then
16381-
ac_fn_c_check_func "$LINENO" "pthread_barrier_wait" "ac_cv_func_pthread_barrier_wait"
16338+
ac_fn_c_check_func "$LINENO" "pthread_barrier_wait" "ac_cv_func_pthread_barrier_wait"
1638216339
if test "x$ac_cv_func_pthread_barrier_wait" = xyes; then :
1638316340
$as_echo "#define HAVE_PTHREAD_BARRIER_WAIT 1" >>confdefs.h
1638416341

@@ -16392,7 +16349,6 @@ esac
1639216349
fi
1639316350

1639416351

16395-
fi
1639616352

1639716353
if test "$PORTNAME" = "win32" -o "$PORTNAME" = "cygwin"; then
1639816354
# Cygwin and (apparently, based on test results) Mingw both

configure.ac

+5-21
Original file line numberDiff line numberDiff line change
@@ -837,18 +837,6 @@ for dir in $LIBRARY_DIRS $SRCH_LIB; do
837837
done
838838
IFS=$ac_save_IFS
839839

840-
#
841-
# Enable thread-safe client libraries
842-
#
843-
AC_MSG_CHECKING([allow thread-safe client libraries])
844-
PGAC_ARG_BOOL(enable, thread-safety, yes, [disable thread-safety in client libraries])
845-
if test "$enable_thread_safety" = yes; then
846-
AC_DEFINE([ENABLE_THREAD_SAFETY], 1,
847-
[Define to 1 to build client libraries as thread-safe code. (--enable-thread-safety)])
848-
fi
849-
AC_MSG_RESULT([$enable_thread_safety])
850-
AC_SUBST(enable_thread_safety)
851-
852840
#
853841
# ICU
854842
#
@@ -1243,7 +1231,7 @@ dnl note: We have to use AS_IF here rather than plain if. The AC_CHECK_HEADER
12431231
dnl invocation below is the first one in the script, and autoconf generates
12441232
dnl additional code for that, which must not be inside the if-block. AS_IF
12451233
dnl knows how to do that.
1246-
AS_IF([test "$enable_thread_safety" = yes -a "$PORTNAME" != "win32"],
1234+
AS_IF([test "$PORTNAME" != "win32"],
12471235
[ # then
12481236
AX_PTHREAD # set thread flags
12491237
@@ -1258,7 +1246,7 @@ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
12581246
LIBS="$LIBS $PTHREAD_LIBS"
12591247
12601248
AC_CHECK_HEADER(pthread.h, [], [AC_MSG_ERROR([
1261-
pthread.h not found; use --disable-thread-safety to disable thread safety])])
1249+
pthread.h not found])])
12621250
12631251
AC_CHECK_FUNCS([strerror_r])
12641252
@@ -1305,9 +1293,7 @@ AC_SEARCH_LIBS(shmget, cygipc)
13051293
# *BSD:
13061294
AC_SEARCH_LIBS(backtrace_symbols, execinfo)
13071295

1308-
if test "$enable_thread_safety" = yes; then
1309-
AC_SEARCH_LIBS(pthread_barrier_wait, pthread)
1310-
fi
1296+
AC_SEARCH_LIBS(pthread_barrier_wait, pthread)
13111297

13121298
if test "$with_readline" = yes; then
13131299
PGAC_CHECK_READLINE
@@ -1434,7 +1420,7 @@ if test "$with_ldap" = yes ; then
14341420
AC_CHECK_FUNC([ldap_verify_credentials],
14351421
[thread_safe_libldap=yes],
14361422
[thread_safe_libldap=no])
1437-
if test "$enable_thread_safety" = yes -a "$thread_safe_libldap" = no; then
1423+
if test "$thread_safe_libldap" = no; then
14381424
# Use ldap_r for FE if available, else assume ldap is thread-safe.
14391425
# On some platforms ldap_r fails to link without PTHREAD_LIBS.
14401426
LIBS="$_LIBS"
@@ -1858,9 +1844,7 @@ AC_REPLACE_FUNCS(m4_normalize([
18581844
strnlen
18591845
]))
18601846

1861-
if test "$enable_thread_safety" = yes; then
1862-
AC_REPLACE_FUNCS(pthread_barrier_wait)
1863-
fi
1847+
AC_REPLACE_FUNCS(pthread_barrier_wait)
18641848

18651849
if test "$PORTNAME" = "win32" -o "$PORTNAME" = "cygwin"; then
18661850
# Cygwin and (apparently, based on test results) Mingw both

doc/src/sgml/installation.sgml

-13
Original file line numberDiff line numberDiff line change
@@ -1306,19 +1306,6 @@ build-postgresql:
13061306
</listitem>
13071307
</varlistentry>
13081308

1309-
<varlistentry id="configure-option-disable-thread-safety">
1310-
<term><option>--disable-thread-safety</option></term>
1311-
<listitem>
1312-
<para>
1313-
Disable the thread-safety of client libraries. This prevents
1314-
concurrent threads in <application>libpq</application> and
1315-
<application>ECPG</application> programs from safely controlling
1316-
their private connection handles. Use this only on platforms
1317-
with deficient threading support.
1318-
</para>
1319-
</listitem>
1320-
</varlistentry>
1321-
13221309
</variablelist>
13231310

13241311
</sect3>

meson.build

-11
Original file line numberDiff line numberDiff line change
@@ -2508,17 +2508,6 @@ cdata.set_quoted('PG_VERSION_STR',
25082508
)
25092509

25102510

2511-
2512-
###############################################################
2513-
# Threading
2514-
###############################################################
2515-
2516-
# XXX: About to rely on thread safety in the autoconf build, so not worth
2517-
# implementing a fallback.
2518-
cdata.set('ENABLE_THREAD_SAFETY', 1)
2519-
2520-
2521-
25222511
###############################################################
25232512
# NLS / Gettext
25242513
###############################################################

src/Makefile.global.in

-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ enable_debug = @enable_debug@
202202
enable_dtrace = @enable_dtrace@
203203
enable_coverage = @enable_coverage@
204204
enable_tap_tests = @enable_tap_tests@
205-
enable_thread_safety = @enable_thread_safety@
206205

207206
python_includespec = @python_includespec@
208207
python_libdir = @python_libdir@

src/bin/pgbench/pgbench.c

+1-21
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ typedef struct socket_set
137137
EnterSynchronizationBarrier((barrier), \
138138
SYNCHRONIZATION_BARRIER_FLAGS_BLOCK_ONLY)
139139
#define THREAD_BARRIER_DESTROY(barrier)
140-
#elif defined(ENABLE_THREAD_SAFETY)
140+
#else
141141
/* Use POSIX threads */
142142
#include "port/pg_pthread.h"
143143
#define THREAD_T pthread_t
@@ -153,16 +153,6 @@ typedef struct socket_set
153153
pthread_barrier_init((barrier), NULL, (n))
154154
#define THREAD_BARRIER_WAIT(barrier) pthread_barrier_wait((barrier))
155155
#define THREAD_BARRIER_DESTROY(barrier) pthread_barrier_destroy((barrier))
156-
#else
157-
/* No threads implementation, use none (-j 1) */
158-
#define THREAD_T void *
159-
#define THREAD_FUNC_RETURN_TYPE void *
160-
#define THREAD_FUNC_RETURN return NULL
161-
#define THREAD_FUNC_CC
162-
#define THREAD_BARRIER_T int
163-
#define THREAD_BARRIER_INIT(barrier, n) (*(barrier) = 0)
164-
#define THREAD_BARRIER_WAIT(barrier)
165-
#define THREAD_BARRIER_DESTROY(barrier)
166156
#endif
167157

168158

@@ -6749,10 +6739,6 @@ main(int argc, char **argv)
67496739
{
67506740
exit(1);
67516741
}
6752-
#ifndef ENABLE_THREAD_SAFETY
6753-
if (nthreads != 1)
6754-
pg_fatal("threads are not supported on this platform; use -j1");
6755-
#endif /* !ENABLE_THREAD_SAFETY */
67566742
break;
67576743
case 'l':
67586744
benchmarking_option_set = true;
@@ -7236,7 +7222,6 @@ main(int argc, char **argv)
72367222
if (errno != 0)
72377223
pg_fatal("could not initialize barrier: %m");
72387224

7239-
#ifdef ENABLE_THREAD_SAFETY
72407225
/* start all threads but thread 0 which is executed directly later */
72417226
for (i = 1; i < nthreads; i++)
72427227
{
@@ -7248,9 +7233,6 @@ main(int argc, char **argv)
72487233
if (errno != 0)
72497234
pg_fatal("could not create thread: %m");
72507235
}
7251-
#else
7252-
Assert(nthreads == 1);
7253-
#endif /* ENABLE_THREAD_SAFETY */
72547236

72557237
/* compute when to stop */
72567238
threads[0].create_time = pg_time_now();
@@ -7268,10 +7250,8 @@ main(int argc, char **argv)
72687250
{
72697251
TState *thread = &threads[i];
72707252

7271-
#ifdef ENABLE_THREAD_SAFETY
72727253
if (i > 0)
72737254
THREAD_JOIN(thread->thread);
7274-
#endif /* ENABLE_THREAD_SAFETY */
72757255

72767256
for (int j = 0; j < thread->nstate; j++)
72777257
if (thread->state[j].state != CSTATE_FINISHED)

src/include/pg_config.h.in

-4
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,6 @@
5151
/* Define to 1 if you want National Language Support. (--enable-nls) */
5252
#undef ENABLE_NLS
5353

54-
/* Define to 1 to build client libraries as thread-safe code.
55-
(--enable-thread-safety) */
56-
#undef ENABLE_THREAD_SAFETY
57-
5854
/* Define to 1 if you have the `append_history' function. */
5955
#undef HAVE_APPEND_HISTORY
6056

0 commit comments

Comments
 (0)