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

Commitda5aecc

Browse files
committed
Move pqsignal() to libpgport.
We had two copies of this function in the backend and libpq, which wasalready pretty bogus, but it turns out that we need it in some otherprograms that don't use libpq (such as pg_test_fsync). So put it whereit probably should have been all along. The signal-mask-initializationsupport in src/backend/libpq/pqsignal.c stays where it is, though, sincewe only need that in the backend.
1 parentd43837d commitda5aecc

File tree

30 files changed

+99
-184
lines changed

30 files changed

+99
-184
lines changed

‎contrib/pgbench/pgbench.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535

3636
#include"getopt_long.h"
3737
#include"libpq-fe.h"
38-
#include"libpq/pqsignal.h"
3938
#include"portability/instr_time.h"
4039

4140
#include<ctype.h>

‎src/backend/access/transam/xlog.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#include"catalog/catversion.h"
3636
#include"catalog/pg_control.h"
3737
#include"catalog/pg_database.h"
38-
#include"libpq/pqsignal.h"
3938
#include"miscadmin.h"
4039
#include"pgstat.h"
4140
#include"postmaster/bgwriter.h"

‎src/backend/libpq/pqsignal.c

Lines changed: 3 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/*-------------------------------------------------------------------------
22
*
33
* pqsignal.c
4-
* reliable BSD-style signal(2) routine stolen from RWW who stole it
5-
* from Stevens...
4+
* Backend signal(2) support (see also src/port/pqsignal.c)
65
*
76
* Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
87
* Portions Copyright (c) 1994, Regents of the University of California
@@ -11,38 +10,11 @@
1110
* IDENTIFICATION
1211
* src/backend/libpq/pqsignal.c
1312
*
14-
* NOTES
15-
*This shouldn't be in libpq, but the monitor and some other
16-
*things need it...
17-
*
18-
*A NOTE ABOUT SIGNAL HANDLING ACROSS THE VARIOUS PLATFORMS.
19-
*
20-
*pg_config.h defines the macro HAVE_POSIX_SIGNALS for some platforms and
21-
*not for others. This file and pqsignal.h use that macro to decide
22-
*how to handle signalling.
23-
*
24-
*signal(2) handling - this is here because it affects some of
25-
*the frontend commands as well as the backend processes.
26-
*
27-
*Ultrix and SunOS provide BSD signal(2) semantics by default.
28-
*
29-
*SVID2 and POSIX signal(2) semantics differ from BSD signal(2)
30-
*semantics.We can use the POSIX sigaction(2) on systems that
31-
*allow us to request restartable signals (SA_RESTART).
32-
*
33-
*Some systems don't allow restartable signals at all unless we
34-
*link to a special BSD library.
35-
*
36-
*We devoutly hope that there aren't any systems that provide
37-
*neither POSIX signals nor BSD signals.The alternative
38-
*is to do signal-handler reinstallation, which doesn't work well
39-
*at all.
40-
* ------------------------------------------------------------------------*/
13+
* ------------------------------------------------------------------------
14+
*/
4115

4216
#include"postgres.h"
4317

44-
#include<signal.h>
45-
4618
#include"libpq/pqsignal.h"
4719

4820

@@ -145,36 +117,3 @@ pqinitmask(void)
145117
sigmask(SIGWINCH) |sigmask(SIGFPE);
146118
#endif
147119
}
148-
149-
150-
/* Win32 signal handling is in backend/port/win32/signal.c */
151-
#ifndefWIN32
152-
153-
/*
154-
* Set up a signal handler
155-
*/
156-
pqsigfunc
157-
pqsignal(intsigno,pqsigfuncfunc)
158-
{
159-
#if !defined(HAVE_POSIX_SIGNALS)
160-
returnsignal(signo,func);
161-
#else
162-
structsigactionact,
163-
oact;
164-
165-
act.sa_handler=func;
166-
sigemptyset(&act.sa_mask);
167-
act.sa_flags=0;
168-
if (signo!=SIGALRM)
169-
act.sa_flags |=SA_RESTART;
170-
#ifdefSA_NOCLDSTOP
171-
if (signo==SIGCHLD)
172-
act.sa_flags |=SA_NOCLDSTOP;
173-
#endif
174-
if (sigaction(signo,&act,&oact)<0)
175-
returnSIG_ERR;
176-
returnoact.sa_handler;
177-
#endif/* !HAVE_POSIX_SIGNALS */
178-
}
179-
180-
#endif/* WIN32 */

‎src/backend/main/main.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@
4141
#include"utils/help_config.h"
4242
#include"utils/pg_locale.h"
4343
#include"utils/ps_status.h"
44-
#ifdefWIN32
45-
#include"libpq/pqsignal.h"
46-
#endif
4744

4845

4946
constchar*progname;

‎src/backend/port/win32/signal.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
#include"postgres.h"
1515

16-
#include<libpq/pqsignal.h>
16+
#include"libpq/pqsignal.h"
1717

1818
/*
1919
* These are exported for use by the UNBLOCKED_SIGNAL_QUEUE() macro.
@@ -158,7 +158,11 @@ pqsigsetmask(int mask)
158158
}
159159

160160

161-
/* signal manipulation. Only called on main thread, no sync required */
161+
/*
162+
* Unix-like signal handler installation
163+
*
164+
* Only called on main thread, no sync required
165+
*/
162166
pqsigfunc
163167
pqsignal(intsignum,pqsigfunchandler)
164168
{

‎src/backend/port/win32/timer.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818

1919
#include"postgres.h"
2020

21-
#include"libpq/pqsignal.h"
22-
2321

2422
/* Communication area for inter-thread communication */
2523
typedefstructtimerCA

‎src/backend/replication/walsender.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
#include"funcapi.h"
5050
#include"libpq/libpq.h"
5151
#include"libpq/pqformat.h"
52-
#include"libpq/pqsignal.h"
5352
#include"miscadmin.h"
5453
#include"nodes/replnodes.h"
5554
#include"replication/basebackup.h"

‎src/backend/utils/misc/timeout.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
#include<sys/time.h>
1818

19-
#include"libpq/pqsignal.h"
2019
#include"storage/proc.h"
2120
#include"utils/timeout.h"
2221
#include"utils/timestamp.h"

‎src/bin/initdb/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/encnames.c
2-
/pqsignal.c
32
/localtime.c
43

54
/initdb

‎src/bin/initdb/Makefile

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,20 @@ ifneq (,$(with_system_tzdata))
2323
overrideCPPFLAGS += '-DSYSTEMTZDIR="$(with_system_tzdata)"'
2424
endif
2525

26-
OBJS=initdb.o findtimezone.o localtime.o encnames.opqsignal.o$(WIN32RES)
26+
OBJS=initdb.o findtimezone.o localtime.o encnames.o$(WIN32RES)
2727

2828
all: initdb
2929

3030
initdb:$(OBJS) | submake-libpgport
3131
$(CC)$(CFLAGS)$(OBJS)$(LDFLAGS)$(LDFLAGS_EX)$(LIBS) -o$@$(X)
3232

33-
# We used to pull in all of libpq to get encnames and pqsignal, but that
33+
# We used to pull in all of libpq to get encnames.c, but that
3434
# exposes us to risks of version skew if we link to a shared library.
3535
# Do it the hard way, instead, so that we're statically linked.
3636

3737
encnames.c:% :$(top_srcdir)/src/backend/utils/mb/%
3838
rm -f$@&&$(LN_S)$<.
3939

40-
pqsignal.c:% :$(top_srcdir)/src/interfaces/libpq/%
41-
rm -f$@&&$(LN_S)$<.
42-
4340
# Likewise, pull in localtime.c from src/timezones
4441

4542
localtime.c:% :$(top_srcdir)/src/timezone/%
@@ -55,7 +52,7 @@ uninstall:
5552
rm -f'$(DESTDIR)$(bindir)/initdb$(X)'
5653

5754
cleandistcleanmaintainer-clean:
58-
rm -f initdb$(X)$(OBJS) encnames.cpqsignal.clocaltime.c
55+
rm -f initdb$(X)$(OBJS) encnames.c localtime.c
5956

6057

6158
# ensure that changes in datadir propagate into object file

‎src/bin/initdb/initdb.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
#include<signal.h>
5757
#include<time.h>
5858

59-
#include"libpq/pqsignal.h"
6059
#include"mb/pg_wchar.h"
6160
#include"getaddrinfo.h"
6261
#include"getopt_long.h"

‎src/bin/pg_basebackup/pg_receivexlog.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
#include"postgres_fe.h"
1616
#include"libpq-fe.h"
17-
#include"libpq/pqsignal.h"
1817
#include"access/xlog_internal.h"
1918

2019
#include"receivelog.h"

‎src/bin/pg_ctl/pg_ctl.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include<sys/resource.h>
3434
#endif
3535

36-
#include"libpq/pqsignal.h"
3736
#include"getopt_long.h"
3837
#include"miscadmin.h"
3938

‎src/bin/psql/common.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919

2020
#include"portability/instr_time.h"
2121

22-
#include"pqsignal.h"
23-
2422
#include"settings.h"
2523
#include"command.h"
2624
#include"copy.h"

‎src/bin/psql/copy.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
#include"libpq-fe.h"
2020
#include"pqexpbuffer.h"
21-
#include"pqsignal.h"
2221
#include"dumputils.h"
2322

2423
#include"settings.h"

‎src/bin/psql/print.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include<locale.h>
2424

2525
#include"catalog/pg_type.h"
26-
#include"pqsignal.h"
2726

2827
#include"common.h"
2928
#include"mbprint.h"

‎src/bin/scripts/common.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include<unistd.h>
2020

2121
#include"common.h"
22-
#include"libpq/pqsignal.h"
2322

2423
staticvoidSetCancelConn(PGconn*conn);
2524
staticvoidResetCancelConn(void);

‎src/include/libpq/pqsignal.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
/*-------------------------------------------------------------------------
22
*
33
* pqsignal.h
4-
* prototypes for the reliable BSD-style signal(2) routine.
5-
*
4+
* Backend signal(2) support (see also src/port/pqsignal.c)
65
*
76
* Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
87
* Portions Copyright (c) 1994, Regents of the University of California
98
*
109
* src/include/libpq/pqsignal.h
1110
*
12-
* NOTES
13-
* This shouldn't be in libpq, but the monitor and some other
14-
* things need it...
15-
*
1611
*-------------------------------------------------------------------------
1712
*/
1813
#ifndefPQSIGNAL_H
@@ -42,10 +37,6 @@ intpqsigsetmask(int mask);
4237
#definesigdelset(set,signum)(*(set) &= ~(sigmask(signum)))
4338
#endif/* not HAVE_SIGPROCMASK */
4439

45-
typedefvoid (*pqsigfunc) (int);
46-
4740
externvoidpqinitmask(void);
4841

49-
externpqsigfuncpqsignal(intsigno,pqsigfuncfunc);
50-
5142
#endif/* PQSIGNAL_H */

‎src/include/port.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,13 @@ extern intpg_check_dir(const char *dir);
462462
/* port/pgmkdirp.c */
463463
externintpg_mkdir_p(char*path,intomode);
464464

465+
/* port/pqsignal.c */
466+
/* On Windows, we can emulate pqsignal in the backend, but not frontend */
467+
#if !defined(WIN32)|| !defined(FRONTEND)
468+
typedefvoid (*pqsigfunc) (intsigno);
469+
externpqsigfuncpqsignal(intsigno,pqsigfuncfunc);
470+
#endif
471+
465472
/* port/quotes.c */
466473
externchar*escape_single_quotes_ascii(constchar*src);
467474

‎src/interfaces/libpq/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ LIBS := $(LIBS:-lpgport=)
3232
# We can't use Makefile variables here because the MSVC build system scrapes
3333
# OBJS from this file.
3434
OBJS=fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o\
35-
fe-protocol2.o fe-protocol3.o pqexpbuffer.opqsignal.ofe-secure.o\
35+
fe-protocol2.o fe-protocol3.o pqexpbuffer.o fe-secure.o\
3636
libpq-events.o
3737
# libpgport C files we always use
3838
OBJS += chklocale.o inet_net_ntop.o noblock.o pgstrcasecmp.o thread.o

‎src/interfaces/libpq/bcc32.mak

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ CLEAN :
9595
-@erase"$(INTDIR)\fe-secure.obj"
9696
-@erase"$(INTDIR)\libpq-events.obj"
9797
-@erase"$(INTDIR)\pqexpbuffer.obj"
98-
-@erase"$(INTDIR)\pqsignal.obj"
9998
-@erase"$(INTDIR)\win32.obj"
10099
-@erase"$(INTDIR)\wchar.obj"
101100
-@erase"$(INTDIR)\encnames.obj"
@@ -140,7 +139,6 @@ LIB32_OBJS= \
140139
"$(INTDIR)\fe-secure.obj"\
141140
"$(INTDIR)\libpq-events.obj"\
142141
"$(INTDIR)\pqexpbuffer.obj"\
143-
"$(INTDIR)\pqsignal.obj"\
144142
"$(INTDIR)\wchar.obj"\
145143
"$(INTDIR)\encnames.obj"\
146144
"$(INTDIR)\snprintf.obj"\

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555

5656
#include"libpq-fe.h"
5757
#include"libpq-int.h"
58-
#include"pqsignal.h"
5958
#include"mb/pg_wchar.h"
6059
#include"pg_config_paths.h"
6160

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535

3636
#include"libpq-fe.h"
3737
#include"libpq-int.h"
38-
#include"pqsignal.h"
3938

4039

4140
staticvoiddo_field(constPQprintOpt*po,constPGresult*res,

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030

3131
#include"libpq-fe.h"
3232
#include"fe-auth.h"
33-
#include"pqsignal.h"
3433
#include"libpq-int.h"
3534

3635
#ifdefWIN32

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp