Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit02d847f

Browse files
committed
Add --with-threads configure option to control threaded libpq.
1 parent26188e8 commit02d847f

File tree

5 files changed

+112
-42
lines changed

5 files changed

+112
-42
lines changed

‎configure

Lines changed: 63 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,7 @@ Optional Packages:
855855
--with-libraries=DIRS look for additional libraries in DIRS
856856
--with-libs=DIRS alternative spelling of --with-libraries
857857
--with-pgport=PORTNUM change default port number 5432
858+
--with-threads allow libpq to be thread-safe
858859
--with-tcl build Tcl and Tk interfaces
859860
--without-tk do not build Tk interfaces if Tcl is enabled
860861
--with-tclconfig=DIR tclConfig.sh and tkConfig.sh are in DIR
@@ -2809,6 +2810,41 @@ echo "$as_me: WARNING: *** Library directory $dir does not exist." >&2;}
28092810
done
28102811
IFS=$ac_save_IFS
28112812
2813+
#
2814+
# Enable libpq to be thread-safe
2815+
#
2816+
echo"$as_me:$LINENO: checking allow threaded libpq">&5
2817+
echo$ECHO_N"checking allow threaded libpq...$ECHO_C">&6
2818+
2819+
2820+
2821+
# Check whether --with-threads or --without-threads was given.
2822+
iftest"${with_threads+set}" =set;then
2823+
withval="$with_threads"
2824+
2825+
case$withvalin
2826+
yes)
2827+
:
2828+
;;
2829+
no)
2830+
:
2831+
;;
2832+
*)
2833+
{ {echo"$as_me:$LINENO: error: no argument expected for --with-threads option">&5
2834+
echo"$as_me: error: no argument expected for --with-threads option">&2;}
2835+
{ (exit 1);exit 1; }; }
2836+
;;
2837+
esac
2838+
2839+
else
2840+
with_threads=no
2841+
2842+
fi;
2843+
2844+
echo"$as_me:$LINENO: result:$with_threads">&5
2845+
echo"${ECHO_T}$with_threads">&6
2846+
2847+
28122848
#
28132849
# Tcl/Tk
28142850
#
@@ -3550,7 +3586,7 @@ rm -f conftest*
35503586
#
35513587
# Pthreads
35523588
#
3553-
3589+
iftest"$with_threads" = yes;then
35543590
echo"$as_me:$LINENO: checking for ANSI C header files">&5
35553591
echo$ECHO_N"checking for ANSI C header files...$ECHO_C">&6
35563592
iftest"${ac_cv_header_stdc+set}" =set;then
@@ -3850,25 +3886,38 @@ echo "${ECHO_T}$ac_cv_header_pthread_h" >&6
38503886
38513887
fi
38523888
iftest$ac_cv_header_pthread_h = yes;then
3853-
3854-
cat>>confdefs.h<<\_ACEOF
3855-
#define HAVE_THREADS 1
3856-
_ACEOF
3857-
3889+
:
3890+
else
3891+
{ {echo"$as_me:$LINENO: error: pthread.h not found, required for --with-threads">&5
3892+
echo"$as_me: error: pthread.h not found, required for --with-threads">&2;}
3893+
{ (exit 1);exit 1; }; }
38583894
fi
38593895
38603896
3861-
iftest! -z"$HAVE_THREADS"
3862-
then
3863-
case$host_osin
3864-
# BSD/OS and NetBSD require no special libraries or flags
3865-
netbsd*|bsdi*) ;;
3897+
case$host_osin
3898+
netbsd*|bsdi*)
3899+
# these require no special flags or libraries
3900+
;;
38663901
freebsd2*|freebsd3*|freebsd4*) THREAD_CFLAGS="-pthread" ;;
38673902
freebsd*) THREAD_LIBS="-lc_r" ;;
38683903
linux*) THREAD_LIBS="-lpthread"
38693904
THREAD_CFLAGS="-D_REENTRANT" ;;
3870-
# other operating systems might fail because they have pthread.h but need
3871-
# special libs we don't know about yet.
3905+
*)
3906+
# other operating systems might fail because they have pthread.h but need
3907+
# special libs we don't know about yet.
3908+
{ {echo"$as_me:$LINENO: error:
3909+
Cannot enable threads on your platform.
3910+
Please report your platform threading info to the PostgreSQL mailing lists
3911+
so it can be added to the next release. Report any compile or link flags,
3912+
or libraries required for threading support.
3913+
">&5
3914+
echo"$as_me: error:
3915+
Cannot enable threads on your platform.
3916+
Please report your platform threading info to the PostgreSQL mailing lists
3917+
so it can be added to the next release. Report any compile or link flags,
3918+
or libraries required for threading support.
3919+
">&2;}
3920+
{ (exit 1);exit 1; }; }
38723921
esac
38733922
fi
38743923
@@ -17540,6 +17589,7 @@ s,@CPP@,$CPP,;t t
1754017589
s,@GCC@,$GCC,;t t
1754117590
s,@autodepend@,$autodepend,;t t
1754217591
s,@INCLUDES@,$INCLUDES,;t t
17592+
s,@with_threads@,$with_threads,;t t
1754317593
s,@with_tcl@,$with_tcl,;t t
1754417594
s,@with_tk@,$with_tk,;t t
1754517595
s,@with_perl@,$with_perl,;t t

‎configure.in

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dnl Process this file with autoconf to produce a configure script.
2-
dnl $Header: /cvsroot/pgsql/configure.in,v 1.260 2003/06/12 16:05:09 tgl Exp $
2+
dnl $Header: /cvsroot/pgsql/configure.in,v 1.261 2003/06/13 23:10:07 momjian Exp $
33
dnl
44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -319,6 +319,14 @@ for dir in $LIBRARY_DIRS $SRCH_LIB; do
319319
done
320320
IFS=$ac_save_IFS
321321

322+
#
323+
# Enable libpq to be thread-safe
324+
#
325+
AC_MSG_CHECKING([allow threaded libpq])
326+
PGAC_ARG_BOOL(with, threads, no, [ --with-threads allow libpq to be thread-safe])
327+
AC_MSG_RESULT([$with_threads])
328+
AC_SUBST(with_threads)
329+
322330
#
323331
# Tcl/Tk
324332
#
@@ -544,20 +552,25 @@ AC_SUBST(ELF_SYS)
544552
#
545553
# Pthreads
546554
#
547-
548-
AC_CHECK_HEADER(pthread.h,
549-
[AC_DEFINE(HAVE_THREADS, 1, [Define to 1 if you have the threads interface.])])
550-
if test ! -z "$HAVE_THREADS"
551-
then
552-
case $host_os in
553-
# BSD/OS and NetBSD require no special libraries or flags
554-
netbsd*|bsdi*) ;;
555+
if test "$with_threads" = yes; then
556+
AC_CHECK_HEADER(pthread.h, [], [AC_MSG_ERROR([pthread.h not found, required for --with-threads])])
557+
case $host_os in
558+
netbsd*|bsdi*)
559+
# these require no special flags or libraries
560+
;;
555561
freebsd2*|freebsd3*|freebsd4*) THREAD_CFLAGS="-pthread" ;;
556562
freebsd*) THREAD_LIBS="-lc_r" ;;
557563
linux*) THREAD_LIBS="-lpthread"
558564
THREAD_CFLAGS="-D_REENTRANT" ;;
559-
# other operating systems might fail because they have pthread.h but need
560-
# special libs we don't know about yet.
565+
*)
566+
# other operating systems might fail because they have pthread.h but need
567+
# special libs we don't know about yet.
568+
AC_MSG_ERROR([
569+
Cannot enable threads on your platform.
570+
Please report your platform threading info to the PostgreSQL mailing lists
571+
so it can be added to the next release. Report any compile or link flags,
572+
or libraries required for threading support.
573+
])
561574
esac
562575
fi
563576
AC_SUBST(THREAD_LIBS)

‎doc/src/sgml/installation.sgml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/installation.sgml,v 1.133 2003/06/11 06:56:06 momjian Exp $ -->
1+
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/installation.sgml,v 1.134 2003/06/13 23:10:07 momjian Exp $ -->
22

33
<chapter id="installation">
44
<title><![%standalone-include[<productname>PostgreSQL</>]]>
@@ -914,6 +914,15 @@ JAVACMD=$JAVA_HOME/bin/java
914914
</listitem>
915915
</varlistentry>
916916

917+
<varlistentry>
918+
<term><option>--with-threads</option></term>
919+
<listitem>
920+
<para>
921+
Allow separate libpq threads to safely control their private connection handles.
922+
</para>
923+
</listitem>
924+
</varlistentry>
925+
917926
<varlistentry>
918927
<term><option>--without-zlib</option></term>
919928
<listitem>

‎doc/src/sgml/libpq.sgml

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/libpq.sgml,v 1.123 2003/05/14 03:25:58 tgl Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/libpq.sgml,v 1.124 2003/06/13 23:10:07 momjian Exp $
33
-->
44

55
<chapter id="libpq">
@@ -509,11 +509,6 @@ typedef struct
509509
is leaked for each call to <function>PQconndefaults</function>.
510510
</para>
511511

512-
<para>
513-
In <productname>PostgreSQL</productname> versions before 7.0, <function>PQconndefaults</function> returned a pointer
514-
to a static array, rather than a dynamically allocated array. That
515-
was not thread-safe, so the behavior has been changed.
516-
</para>
517512
</listitem>
518513
</varlistentry>
519514

@@ -2549,17 +2544,23 @@ If the permissions are less strict than this, the file will be ignored.
25492544
</indexterm>
25502545

25512546
<para>
2552-
<application>libpq</application> is thread-safe as of
2553-
<productname>PostgreSQL</productname> 7.0, so long as no two threads
2554-
attempt to manipulate the same <structname>PGconn</> object at the same
2555-
time. In particular, you cannot issue concurrent commands from different
2556-
threads through the same connection object. (If you need to run
2557-
concurrent commands, start up multiple connections.)
2547+
<application>libpq</application> is thread-safe if the library is
2548+
compiled using the <literal>--with-threads</>
2549+
<filename>configure</filename> command-line option. (You might need to
2550+
use other threading command-line options to compile your client code.)
2551+
</para>
2552+
2553+
<para>
2554+
One restriction is that no two threads attempt to manipulate the same
2555+
<structname>PGconn</> object at the same time. In particular, you cannot
2556+
issue concurrent commands from different threads through the same
2557+
connection object. (If you need to run concurrent commands, start up
2558+
multiple connections.)
25582559
</para>
25592560

25602561
<para>
2561-
<structname>PGresult</> objects are read-only after creation, and so can bepassed around
2562-
freely between threads.
2562+
<structname>PGresult</> objects are read-only after creation, and so can be
2563+
passed aroundfreely between threads.
25632564
</para>
25642565

25652566
<para>

‎src/include/pg_config.h.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,9 +468,6 @@
468468
/* Define to 1 if you have the <termios.h> header file. */
469469
#undef HAVE_TERMIOS_H
470470

471-
/* Define to 1 if you have the threads interface. */
472-
#undef HAVE_THREADS
473-
474471
/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use
475472
`HAVE_STRUCT_TM_TM_ZONE' instead. */
476473
#undef HAVE_TM_ZONE

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp