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

Commit43bf3a6

Browse files
committed
The attached patch updates the thread test program to run stand-alone on
Windows. The test itself is bypassed in configure as discussed, andlibpq has been updated appropriately to allow it to build in thread-safemode.Dave Page
1 parentf2cec87 commit43bf3a6

File tree

12 files changed

+227
-66
lines changed

12 files changed

+227
-66
lines changed

‎configure

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20908,6 +20908,8 @@ fi
2090820908

2090920909

2091020910

20911+
if test x"$template" != x"win32"
20912+
then
2091120913
echo "$as_me:$LINENO: checking for POSIX signal interface" >&5
2091220914
echo $ECHO_N "checking for POSIX signal interface... $ECHO_C" >&6
2091320915
if test "${pgac_cv_func_posix_signals+set}" = set; then
@@ -20986,6 +20988,7 @@ echo "$as_me: error:
2098620988
" >&2;}
2098720989
{ (exit 1); exit 1; }; }
2098820990
fi
20991+
fi
2098920992

2099020993
if test $ac_cv_func_fseeko = yes; then
2099120994
# Check whether --enable-largefile or --disable-largefile was given.
@@ -22432,6 +22435,8 @@ done
2243222435
# defined. Cross compiling throws a warning.
2243322436
#
2243422437
if test "$enable_thread_safety_force" = yes; then
22438+
if test x"$template" != x"win32"
22439+
then
2243522440
{ echo "$as_me:$LINENO: WARNING:
2243622441
*** Skipping thread test program. --enable-thread-safety-force was used.
2243722442
*** Run the program in src/tools/thread on the your machine and add
@@ -22444,7 +22449,13 @@ echo "$as_me: WARNING:
2244422449
proper locking function calls to your applications to guarantee thread
2244522450
safety.
2244622451
" >&2;}
22452+
else
22453+
{ echo "$as_me:$LINENO: WARNING: *** Skipping thread test on Win32" >&5
22454+
echo "$as_me: WARNING: *** Skipping thread test on Win32" >&2;}
22455+
fi
2244722456
elif test "$enable_thread_safety" = yes; then
22457+
if test x"$template" != x"win32"
22458+
then
2244822459
echo "$as_me:$LINENO: checking thread safety of required library functions" >&5
2244922460
echo $ECHO_N "checking thread safety of required library functions... $ECHO_C" >&6
2245022461

@@ -22517,6 +22528,10 @@ rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftes
2251722528
fi
2251822529
CFLAGS="$_CFLAGS"
2251922530
LIBS="$_LIBS"
22531+
else
22532+
{ echo "$as_me:$LINENO: WARNING: *** Skipping thread test on Win32" >&5
22533+
echo "$as_me: WARNING: *** Skipping thread test on Win32" >&2;}
22534+
fi
2252022535
fi
2252122536

2252222537
# prepare build tree if outside source tree

‎configure.in

Lines changed: 14 additions & 1 deletion
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 $PostgreSQL: pgsql/configure.in,v 1.422 2005/08/2320:48:44 momjian Exp $
2+
dnl $PostgreSQL: pgsql/configure.in,v 1.423 2005/08/2321:01:59 momjian Exp $
33
dnl
44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -1172,13 +1172,16 @@ AC_CHECK_TYPES([int8, uint8, int64, uint64], [], [],
11721172
AC_CHECK_TYPES(sig_atomic_t, [], [], [#include <signal.h>])
11731173

11741174

1175+
if test x"$template" != x"win32"
1176+
then
11751177
PGAC_FUNC_POSIX_SIGNALS
11761178
if test "$pgac_cv_func_posix_signals" != yes -a "$enable_thread_safety" = yes; then
11771179
AC_MSG_ERROR([
11781180
*** Thread-safety requires POSIX signals, which are not supported by your
11791181
*** operating system.
11801182
])
11811183
fi
1184+
fi
11821185

11831186
if test $ac_cv_func_fseeko = yes; then
11841187
AC_SYS_LARGEFILE
@@ -1241,13 +1244,20 @@ AC_CHECK_PROGS(SGMLSPL, sgmlspl)
12411244
# defined. Cross compiling throws a warning.
12421245
#
12431246
if test "$enable_thread_safety_force" = yes; then
1247+
if test x"$template" != x"win32"
1248+
then
12441249
AC_MSG_WARN([
12451250
*** Skipping thread test program. --enable-thread-safety-force was used.
12461251
*** Run the program in src/tools/thread on the your machine and add
12471252
proper locking function calls to your applications to guarantee thread
12481253
safety.
12491254
])
1255+
else
1256+
AC_MSG_WARN([*** Skipping thread test on Win32])
1257+
fi
12501258
elif test "$enable_thread_safety" = yes; then
1259+
if test x"$template" != x"win32"
1260+
then
12511261
AC_MSG_CHECKING([thread safety of required library functions])
12521262

12531263
_CFLAGS="$CFLAGS"
@@ -1273,6 +1283,9 @@ AC_TRY_RUN([#include "$srcdir/src/tools/thread/thread_test.c"],
12731283
])])
12741284
CFLAGS="$_CFLAGS"
12751285
LIBS="$_LIBS"
1286+
else
1287+
AC_MSG_WARN([*** Skipping thread test on Win32])
1288+
fi
12761289
fi
12771290

12781291
# prepare build tree if outside source tree

‎src/interfaces/libpq/Makefile

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
66
# Portions Copyright (c) 1994, Regents of the University of California
77
#
8-
# $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.136 2005/08/2320:48:46 momjian Exp $
8+
# $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.137 2005/08/2321:02:03 momjian Exp $
99
#
1010
#-------------------------------------------------------------------------
1111

@@ -43,9 +43,7 @@ libpqrc.o: libpq.rc
4343
windres -i libpq.rc -o libpqrc.o
4444

4545
ifeq ($(enable_thread_safety), yes)
46-
# This doesn't work yet because configure test fails. 2004-06-19
4746
OBJS += pthread-win32.o
48-
PTHREAD_H_WIN32 = pthread.h
4947
endif
5048
endif
5149

@@ -59,7 +57,7 @@ SHLIB_LINK += -lshfolder -lwsock32 -lws2_32 $(filter -leay32 -lssleay32 -lcomerr
5957
endif
6058

6159

62-
all:$(PTHREAD_H_WIN32)def-files$(srcdir)/libpq.rc all-lib
60+
all: def-files$(srcdir)/libpq.rc all-lib
6361

6462
# Shared library stuff
6563
include$(top_srcdir)/src/Makefile.shlib
@@ -122,11 +120,6 @@ $(srcdir)/blibpqdll.def: exports.txt
122120
$(srcdir)/libpq.rc: libpq.rc.in$(top_builddir)/src/Makefile.global
123121
sed -e's/\(VERSION.*\),0 *$$/\1,'`date'+%y%j'| sed's/^0*//'`'/'<$<>$@
124122

125-
ifneq ($(PTHREAD_H_WIN32), "")
126-
pthread.h:$(top_srcdir)/src/interfaces/libpq/pthread.h.win
127-
rm -f$@&&$(LN_S)$<.
128-
endif
129-
130123
fe-connect.o: fe-connect.c$(top_builddir)/src/port/pg_config_paths.h
131124

132125
$(top_builddir)/src/port/pg_config_paths.h:

‎src/interfaces/libpq/fe-connect.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.319 2005/08/2320:48:46 momjian Exp $
11+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.320 2005/08/2321:02:03 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -55,8 +55,12 @@
5555
#endif
5656

5757
#ifdefENABLE_THREAD_SAFETY
58+
#ifdefWIN32
59+
#include"pthread-win32.h"
60+
#else
5861
#include<pthread.h>
5962
#endif
63+
#endif
6064

6165
#include"libpq/ip.h"
6266
#include"mb/pg_wchar.h"

‎src/interfaces/libpq/fe-exec.c

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.173 2005/08/2320:48:47 momjian Exp $
11+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.174 2005/08/2321:02:03 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -2156,25 +2156,16 @@ PQoidValue(const PGresult *res)
21562156
char*endptr=NULL;
21572157
unsigned longresult;
21582158

2159-
if (!res|| !res->cmdStatus||strncmp(res->cmdStatus,"INSERT ",7)!=0)
2159+
if (!res||
2160+
!res->cmdStatus||
2161+
strncmp(res->cmdStatus,"INSERT ",7)!=0||
2162+
res->cmdStatus[7]<'0'||
2163+
res->cmdStatus[7]>'9')
21602164
returnInvalidOid;
21612165

2162-
#ifdefWIN32
2163-
SetLastError(0);
2164-
#else
2165-
errno=0;
2166-
#endif
21672166
result=strtoul(res->cmdStatus+7,&endptr,10);
21682167

2169-
if (!endptr|| (*endptr!=' '&&*endptr!='\0')
2170-
#ifndefWIN32
2171-
/*
2172-
*On WIN32, errno is not thread-safe and GetLastError() isn't set by
2173-
*strtoul(), so we can't check on this platform.
2174-
*/
2175-
||errno==ERANGE
2176-
#endif
2177-
)
2168+
if (!endptr|| (*endptr!=' '&&*endptr!='\0'))
21782169
returnInvalidOid;
21792170
else
21802171
return (Oid)result;

‎src/interfaces/libpq/fe-misc.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* Portions Copyright (c) 1994, Regents of the University of California
2424
*
2525
* IDENTIFICATION
26-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-misc.c,v 1.118 2005/08/2320:48:47 momjian Exp $
26+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-misc.c,v 1.119 2005/08/2321:02:03 momjian Exp $
2727
*
2828
*-------------------------------------------------------------------------
2929
*/
@@ -1133,7 +1133,11 @@ libpq_gettext(const char *msgid)
11331133
if (!already_bound)
11341134
{
11351135
/* dgettext() preserves errno, but bindtextdomain() doesn't */
1136-
intsave_errno=errno;
1136+
#ifdefWIN32
1137+
intsave_errno=GetLastError();
1138+
#else
1139+
intsave_errno=errno;
1140+
#endif
11371141
constchar*ldir;
11381142

11391143
already_bound= true;

‎src/interfaces/libpq/fe-print.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* didn't really belong there.
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-print.c,v 1.62 2005/08/2320:48:47 momjian Exp $
13+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-print.c,v 1.63 2005/08/2321:02:03 momjian Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -88,7 +88,7 @@ PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po)
8888
inttotal_line_length=0;
8989
intusePipe=0;
9090
char*pagerenv;
91-
#ifdefENABLE_THREAD_SAFETY
91+
#if defined(ENABLE_THREAD_SAFETY)&& !defined(WIN32)
9292
sigset_tosigset;
9393
boolsigpipe_masked= false;
9494
boolsigpipe_pending;
@@ -189,14 +189,14 @@ PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po)
189189
if (fout)
190190
{
191191
usePipe=1;
192+
#ifndefWIN32
192193
#ifdefENABLE_THREAD_SAFETY
193194
if (pq_block_sigpipe(&osigset,&sigpipe_pending)==0)
194195
sigpipe_masked= true;
195196
#else
196-
#ifndefWIN32
197197
oldsigpipehandler=pqsignal(SIGPIPE,SIG_IGN);
198-
#endif
199-
#endif
198+
#endif/* ENABLE_THREAD_SAFETY */
199+
#endif/* WIN32 */
200200
}
201201
else
202202
fout=stdout;
@@ -311,16 +311,15 @@ PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po)
311311
_pclose(fout);
312312
#else
313313
pclose(fout);
314-
#endif
314+
315315
#ifdefENABLE_THREAD_SAFETY
316316
/* we can't easily verify if EPIPE occurred, so say it did */
317317
if (sigpipe_masked)
318318
pq_reset_sigpipe(&osigset,sigpipe_pending, true);
319319
#else
320-
#ifndefWIN32
321320
pqsignal(SIGPIPE,oldsigpipehandler);
322-
#endif
323-
#endif
321+
#endif/* ENABLE_THREAD_SAFETY */
322+
#endif/* WIN32 */
324323
}
325324
if (po->html3&& !po->expanded)
326325
fputs("</table>\n",fout);

‎src/interfaces/libpq/fe-secure.c

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-secure.c,v 1.69 2005/08/2320:48:47 momjian Exp $
14+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-secure.c,v 1.70 2005/08/2321:02:03 momjian Exp $
1515
*
1616
* NOTES
1717
* [ Most of these notes are wrong/obsolete, but perhaps not all ]
@@ -103,8 +103,12 @@
103103
#include<sys/stat.h>
104104

105105
#ifdefENABLE_THREAD_SAFETY
106+
#ifdefWIN32
107+
#include"pthread-win32.h"
108+
#else
106109
#include<pthread.h>
107110
#endif
111+
#endif
108112

109113
#ifndefHAVE_STRDUP
110114
#include"strdup.h"
@@ -388,20 +392,21 @@ ssize_t
388392
pqsecure_write(PGconn*conn,constvoid*ptr,size_tlen)
389393
{
390394
ssize_tn;
391-
395+
396+
#ifndefWIN32
392397
#ifdefENABLE_THREAD_SAFETY
393398
sigset_tosigmask;
394399
boolsigpipe_pending;
395400
boolgot_epipe= false;
396401

402+
397403
if (pq_block_sigpipe(&osigmask,&sigpipe_pending)<0)
398404
return-1;
399405
#else
400-
#ifndefWIN32
401406
pqsigfuncoldsighandler=pqsignal(SIGPIPE,SIG_IGN);
402-
#endif
403-
#endif
404-
407+
#endif/* ENABLE_THREAD_SAFETY */
408+
#endif/* WIN32 */
409+
405410
#ifdefUSE_SSL
406411
if (conn->ssl)
407412
{
@@ -431,7 +436,7 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len)
431436

432437
if (n==-1)
433438
{
434-
#ifdefENABLE_THREAD_SAFETY
439+
#if defined(ENABLE_THREAD_SAFETY)&& !defined(WIN32)
435440
if (SOCK_ERRNO==EPIPE)
436441
got_epipe= true;
437442
#endif
@@ -473,19 +478,19 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len)
473478
#endif
474479
{
475480
n=send(conn->sock,ptr,len,0);
476-
#ifdefENABLE_THREAD_SAFETY
481+
#if defined(ENABLE_THREAD_SAFETY)&& !defined(WIN32)
477482
if (n<0&&SOCK_ERRNO==EPIPE)
478483
got_epipe= true;
479484
#endif
480485
}
481-
486+
487+
#ifndefWIN32
482488
#ifdefENABLE_THREAD_SAFETY
483489
pq_reset_sigpipe(&osigmask,sigpipe_pending,got_epipe);
484490
#else
485-
#ifndefWIN32
486491
pqsignal(SIGPIPE,oldsighandler);
487-
#endif
488-
#endif
492+
#endif/* ENABLE_THREAD_SAFETY */
493+
#endif/* WIN32 */
489494

490495
returnn;
491496
}
@@ -1232,7 +1237,7 @@ PQgetssl(PGconn *conn)
12321237

12331238
#endif/* USE_SSL */
12341239

1235-
#ifdefENABLE_THREAD_SAFETY
1240+
#if defined(ENABLE_THREAD_SAFETY)&& !defined(WIN32)
12361241

12371242
/*
12381243
*Block SIGPIPE for this thread. This prevents send()/write() from exiting

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp