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

Commit09c5e84

Browse files
committed
Change elog(ERROR) to get back to main loop via a plain sigsetjmp,
instead of doing a kill(self, SIGQUIT) and expecting the signal handlerto do it. Also, clean up inconsistent definitions of the sigjmp bufferin the several files that already referenced it.
1 parentd30e2ac commit09c5e84

File tree

6 files changed

+45
-90
lines changed

6 files changed

+45
-90
lines changed

‎src/backend/bootstrap/bootstrap.c

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.57 1999/03/25 03:49:25 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.58 1999/04/20 02:19:53 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -184,24 +184,6 @@ static char *values[MAXATTR];/* cooresponding attribute values */
184184
intnumattr;/* number of attributes for cur. rel */
185185
externbooldisableFsync;/* do not fsync the database */
186186

187-
/* The test for HAVE_SIGSETJMP fails on Linux 2.0.x because the test
188-
*explicitly disallows sigsetjmp being a #define, which is how it
189-
*is declared in Linux. So, to avoid compiler warnings about
190-
*sigsetjmp() being redefined, let's not redefine unless necessary.
191-
* - thomas 1997-12-27
192-
*/
193-
194-
#if !defined(HAVE_SIGSETJMP)&& !defined(sigsetjmp)
195-
staticjmp_bufWarn_restart;
196-
197-
#definesigsetjmp(x,y)setjmp(x)
198-
#definesiglongjmp longjmp
199-
200-
#else
201-
staticsigjmp_bufWarn_restart;
202-
203-
#endif
204-
205187
intDebugMode;
206188
staticGlobalMemorynogc= (GlobalMemory)NULL;/* special no-gc mem
207189
* context */

‎src/backend/tcop/postgres.c

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.106 1999/03/22 16:45:27 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.107 1999/04/20 02:19:53 tgl Exp $
1111
*
1212
* NOTES
1313
* this is the "main" module of the postgres backend and
@@ -21,7 +21,6 @@
2121
#include<string.h>
2222
#include<signal.h>
2323
#include<time.h>
24-
#include<setjmp.h>
2524
#include<sys/time.h>
2625
#include<sys/types.h>
2726
#include<fcntl.h>
@@ -136,15 +135,8 @@ static bool IsEmptyQuery = false;
136135

137136
charrelname[80];/* current relation name */
138137

139-
#if defined(nextstep)
140-
jmp_bufWarn_restart;
141-
142-
#definesigsetjmp(x,y)setjmp(x)
143-
#definesiglongjmp longjmp
144-
#else
138+
/* note: these declarations had better match tcopprot.h */
145139
DLLIMPORTsigjmp_bufWarn_restart;
146-
147-
#endif/* defined(nextstep) */
148140
boolInError;
149141

150142
externintNBuffers;
@@ -829,8 +821,15 @@ pg_exec_query_dest(char *query_string,/* string to execute */
829821
/* --------------------------------
830822
*signal handler routines used in PostgresMain()
831823
*
832-
*handle_warn() is used to catch kill(getpid(),SIGQUIT) which
833-
*occurs when elog(ERROR) is called.
824+
*handle_warn() catches SIGQUIT. It forces control back to the main
825+
*loop, just as if an internal error (elog(ERROR,...)) had occurred.
826+
*elog() used to actually use kill(2) to induce a SIGQUIT to get here!
827+
*But that's not 100% reliable on some systems, so now it does its own
828+
*siglongjmp() instead.
829+
*We still provide the signal catcher so that an error quit can be
830+
*forced externally. This should be done only with great caution,
831+
*however, since an asynchronous signal could leave the system in
832+
*who-knows-what inconsistent state.
834833
*
835834
*quickdie() occurs when signalled by the postmaster.
836835
*Some backend has bought the farm,
@@ -1531,7 +1530,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
15311530
if (!IsUnderPostmaster)
15321531
{
15331532
puts("\nPOSTGRES backend interactive interface ");
1534-
puts("$Revision: 1.106 $ $Date: 1999/03/22 16:45:27 $\n");
1533+
puts("$Revision: 1.107 $ $Date: 1999/04/20 02:19:53 $\n");
15351534
}
15361535

15371536
/* ----------------
@@ -1543,8 +1542,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
15431542
*so that the slaves signal the master to abort the transaction
15441543
*rather than calling AbortCurrentTransaction() themselves.
15451544
*
1546-
*Note: elog(ERROR) causes a kill(getpid(),SIGQUIT) to occur
1547-
* sending us back here.
1545+
*Note: elog(ERROR) does a siglongjmp() to transfer control here.
15481546
* ----------------
15491547
*/
15501548

‎src/backend/utils/error/elog.c

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.40 1999/04/16 06:38:17 ishii Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.41 1999/04/20 02:19:54 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -32,6 +32,7 @@
3232
#include"miscadmin.h"
3333
#include"libpq/libpq.h"
3434
#include"storage/proc.h"
35+
#include"tcop/tcopprot.h"
3536
#include"utils/trace.h"
3637

3738
#ifdefUSE_SYSLOG
@@ -216,24 +217,12 @@ elog(int lev, const char *fmt,...)
216217

217218
if (lev==ERROR)
218219
{
219-
externboolInError;
220-
221220
ProcReleaseSpins(NULL);/* get rid of spinlocks we hold */
222221
if (!InError)
223222
{
224-
if (MyProcPid==0) {
225-
kill(getpid(),SIGQUIT);
226-
}else {
227-
kill(MyProcPid,SIGQUIT);/* abort to traffic cop */
228-
}
229-
pause();
223+
/* exit to main loop */
224+
siglongjmp(Warn_restart,1);
230225
}
231-
232-
/*
233-
* The pause(3) is just to avoid race conditions where the thread
234-
* of control on an MP system gets past here (i.e., the signal is
235-
* not received instantaneously).
236-
*/
237226
}
238227

239228
if (lev==FATAL)

‎src/include/tcop/tcopprot.h

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: tcopprot.h,v 1.17 1999/02/13 23:22:13 momjian Exp $
9+
* $Id: tcopprot.h,v 1.18 1999/04/20 02:19:55 tgl Exp $
1010
*
1111
* OLD COMMENTS
1212
* This file was created so that other c files could get the two
@@ -18,8 +18,26 @@
1818
#ifndefTCOPPROT_H
1919
#defineTCOPPROT_H
2020

21-
#include<executor/execdesc.h>
22-
#include<parser/parse_node.h>
21+
#include<setjmp.h>
22+
#include"executor/execdesc.h"
23+
#include"parser/parse_node.h"
24+
25+
/* Autoconf's test for HAVE_SIGSETJMP fails on Linux 2.0.x because the test
26+
*explicitly disallows sigsetjmp being a #define, which is how it
27+
*is declared in Linux. So, to avoid compiler warnings about
28+
*sigsetjmp() being redefined, let's not redefine unless necessary.
29+
* - thomas 1997-12-27
30+
* Autoconf really ought to be brighter about macro-ized system functions...
31+
* and this code really ought to be in config.h ...
32+
*/
33+
34+
#if !defined(HAVE_SIGSETJMP)&& !defined(sigsetjmp)
35+
#definesigjmp_buf jmp_buf
36+
#definesigsetjmp(x,y)setjmp(x)
37+
#definesiglongjmp longjmp
38+
#endif
39+
externDLLIMPORTsigjmp_bufWarn_restart;
40+
externboolInError;
2341

2442
#ifndefBOOTSTRAP_INCLUDE
2543
externList*pg_parse_and_plan(char*query_string,Oid*typev,intnargs,
@@ -30,7 +48,7 @@ extern void pg_exec_query_acl_override(char *query_string);
3048
externvoid
3149
pg_exec_query_dest(char*query_string,CommandDestdest,boolaclOverride);
3250

33-
#endif/*BOOTSTRAP_HEADER */
51+
#endif/*BOOTSTRAP_INCLUDE */
3452

3553
externvoidhandle_warn(SIGNAL_ARGS);
3654
externvoidquickdie(SIGNAL_ARGS);
@@ -42,4 +60,4 @@ extern int PostgresMain(int argc, char *argv[],
4260
externvoidResetUsage(void);
4361
externvoidShowUsage(void);
4462

45-
#endif/*tcopprotIncluded */
63+
#endif/*TCOPPROT_H */

‎src/pl/plpgsql/src/pl_exec.c

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* procedural language
44
*
55
* IDENTIFICATION
6-
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.8 1999/03/22 16:45:30 momjian Exp $
6+
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.9 1999/04/20 02:19:57 tgl Exp $
77
*
88
* This software is copyrighted by Jan Wieck - Hamburg.
99
*
@@ -55,28 +55,12 @@
5555
#include"fmgr.h"
5656
#include"access/heapam.h"
5757

58+
#include"tcop/tcopprot.h"
5859
#include"utils/syscache.h"
5960
#include"catalog/pg_proc.h"
6061
#include"catalog/pg_type.h"
6162

6263

63-
/************************************************************
64-
* Make Warn_restart from tcop/postgres.c visible for us.
65-
* The longjmp() mechanism of the elog(ERROR,...) makes it
66-
* impossible for us to call exceptions. But at least I
67-
* would like some suggestions about where in the PL function
68-
* the error occured.
69-
*
70-
* It's ugly - Jan
71-
************************************************************/
72-
#if defined(nextstep)
73-
#definesigjmp_bufjmp_buf
74-
#definesigsetjmp(x,y)setjmp(x)
75-
#definesiglongjmplongjmp
76-
#endif
77-
78-
externDLLIMPORTsigjmp_bufWarn_restart;/* in tcop/postgres.c */
79-
8064
staticPLpgSQL_function*error_info_func=NULL;
8165
staticPLpgSQL_stmt*error_info_stmt=NULL;
8266
staticchar*error_info_text=NULL;

‎src/pl/tcl/pltcl.c

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* procedural language (PL)
44
*
55
* IDENTIFICATION
6-
* $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.8 1998/11/27 20:05:27 vadim Exp $
6+
* $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.9 1999/04/20 02:19:59 tgl Exp $
77
*
88
* This software is copyrighted by Jan Wieck - Hamburg.
99
*
@@ -52,6 +52,7 @@
5252
#include"fmgr.h"
5353
#include"access/heapam.h"
5454

55+
#include"tcop/tcopprot.h"
5556
#include"utils/syscache.h"
5657
#include"catalog/pg_proc.h"
5758
#include"catalog/pg_type.h"
@@ -90,23 +91,6 @@ typedef struct pltcl_query_desc
9091
}pltcl_query_desc;
9192

9293

93-
/************************************************************
94-
* Make Warn_restart from tcop/postgres.c visible for us.
95-
* The longjmp() mechanism of the elog(ERROR,...) restart let's
96-
* interpreter levels lay around. So we must tidy up in that
97-
* case and thus, we have to catch the longjmp's sometimes to
98-
* return though all the interpreter levels back.
99-
*
100-
* It's ugly - Jan
101-
************************************************************/
102-
#if defined(nextstep)
103-
#definesigjmp_bufjmp_buf
104-
#definesigsetjmp(x,y)setjmp(x)
105-
#definesiglongjmplongjmp
106-
#endif
107-
108-
externsigjmp_bufWarn_restart;/* in tcop/postgres.c */
109-
11094
/**********************************************************************
11195
* Global data
11296
**********************************************************************/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp