Enable SIGTERM and SIGQUIT during client authentication so
the postmaster can kill the forked off processes when shutdown is requested. Jan
This commit is contained in:
parent
d9044b5637
commit
7e26a8241d
@ -9,7 +9,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/libpq/pqsignal.c,v 1.21 2001/08/24 14:07:49 petere Exp $
|
* $Header: /cvsroot/pgsql/src/backend/libpq/pqsignal.c,v 1.22 2001/09/07 16:12:48 wieck Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* This shouldn't be in libpq, but the monitor and some other
|
* This shouldn't be in libpq, but the monitor and some other
|
||||||
@ -61,6 +61,7 @@ pqinitmask(void)
|
|||||||
#ifdef HAVE_SIGPROCMASK
|
#ifdef HAVE_SIGPROCMASK
|
||||||
sigemptyset(&UnBlockSig);
|
sigemptyset(&UnBlockSig);
|
||||||
sigfillset(&BlockSig);
|
sigfillset(&BlockSig);
|
||||||
|
sigfillset(&AuthBlockSig);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Unmark those signals that should never be blocked. Some of these
|
* Unmark those signals that should never be blocked. Some of these
|
||||||
@ -69,27 +70,41 @@ pqinitmask(void)
|
|||||||
*/
|
*/
|
||||||
#ifdef SIGTRAP
|
#ifdef SIGTRAP
|
||||||
sigdelset(&BlockSig, SIGTRAP);
|
sigdelset(&BlockSig, SIGTRAP);
|
||||||
|
sigdelset(&AuthBlockSig, SIGTRAP);
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGABRT
|
#ifdef SIGABRT
|
||||||
sigdelset(&BlockSig, SIGABRT);
|
sigdelset(&BlockSig, SIGABRT);
|
||||||
|
sigdelset(&AuthBlockSig, SIGABRT);
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGILL
|
#ifdef SIGILL
|
||||||
sigdelset(&BlockSig, SIGILL);
|
sigdelset(&BlockSig, SIGILL);
|
||||||
|
sigdelset(&AuthBlockSig, SIGILL);
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGFPE
|
#ifdef SIGFPE
|
||||||
sigdelset(&BlockSig, SIGFPE);
|
sigdelset(&BlockSig, SIGFPE);
|
||||||
|
sigdelset(&AuthBlockSig, SIGFPE);
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGSEGV
|
#ifdef SIGSEGV
|
||||||
sigdelset(&BlockSig, SIGSEGV);
|
sigdelset(&BlockSig, SIGSEGV);
|
||||||
|
sigdelset(&AuthBlockSig, SIGSEGV);
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGBUS
|
#ifdef SIGBUS
|
||||||
sigdelset(&BlockSig, SIGBUS);
|
sigdelset(&BlockSig, SIGBUS);
|
||||||
|
sigdelset(&AuthBlockSig, SIGBUS);
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGSYS
|
#ifdef SIGSYS
|
||||||
sigdelset(&BlockSig, SIGSYS);
|
sigdelset(&BlockSig, SIGSYS);
|
||||||
|
sigdelset(&AuthBlockSig, SIGSYS);
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGCONT
|
#ifdef SIGCONT
|
||||||
sigdelset(&BlockSig, SIGCONT);
|
sigdelset(&BlockSig, SIGCONT);
|
||||||
|
sigdelset(&AuthBlockSig, SIGCONT);
|
||||||
|
#endif
|
||||||
|
#ifdef SIGTERM
|
||||||
|
sigdelset(&AuthBlockSig, SIGTERM);
|
||||||
|
#endif
|
||||||
|
#ifdef SIGQUIT
|
||||||
|
sigdelset(&AuthBlockSig, SIGQUIT);
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
UnBlockSig = 0;
|
UnBlockSig = 0;
|
||||||
@ -98,6 +113,10 @@ pqinitmask(void)
|
|||||||
sigmask(SIGINT) | sigmask(SIGUSR1) |
|
sigmask(SIGINT) | sigmask(SIGUSR1) |
|
||||||
sigmask(SIGUSR2) | sigmask(SIGCHLD) |
|
sigmask(SIGUSR2) | sigmask(SIGCHLD) |
|
||||||
sigmask(SIGWINCH) | sigmask(SIGFPE);
|
sigmask(SIGWINCH) | sigmask(SIGFPE);
|
||||||
|
AuthBlockSig = sigmask(SIGHUP) | sigmask(SIGALRM) |
|
||||||
|
sigmask(SIGINT) | sigmask(SIGUSR1) |
|
||||||
|
sigmask(SIGUSR2) | sigmask(SIGCHLD) |
|
||||||
|
sigmask(SIGWINCH) | sigmask(SIGFPE);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.239 2001/09/07 00:46:42 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.240 2001/09/07 16:12:48 wieck Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
*
|
*
|
||||||
@ -112,10 +112,12 @@
|
|||||||
|
|
||||||
#ifdef HAVE_SIGPROCMASK
|
#ifdef HAVE_SIGPROCMASK
|
||||||
sigset_t UnBlockSig,
|
sigset_t UnBlockSig,
|
||||||
BlockSig;
|
BlockSig,
|
||||||
|
AuthBlockSig;
|
||||||
#else
|
#else
|
||||||
int UnBlockSig,
|
int UnBlockSig,
|
||||||
BlockSig;
|
BlockSig,
|
||||||
|
AuthBlockSig;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1932,6 +1934,16 @@ DoBackend(Port *port)
|
|||||||
|
|
||||||
whereToSendOutput = Remote; /* XXX probably doesn't belong here */
|
whereToSendOutput = Remote; /* XXX probably doesn't belong here */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We arrange for a simple exit(0) if we receive SIGTERM or SIGQUIT
|
||||||
|
* during any client authentication related communication. Otherwise
|
||||||
|
* the postmaster cannot shutdown the database FAST or IMMED cleanly
|
||||||
|
* if a buggy client blocks a backend during authentication.
|
||||||
|
*/
|
||||||
|
pqsignal(SIGTERM, authdie);
|
||||||
|
pqsignal(SIGQUIT, authdie);
|
||||||
|
PG_SETMASK(&AuthBlockSig);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Receive the startup packet (which might turn out to be a cancel
|
* Receive the startup packet (which might turn out to be a cancel
|
||||||
* request packet); then perform client authentication.
|
* request packet); then perform client authentication.
|
||||||
@ -1943,6 +1955,8 @@ DoBackend(Port *port)
|
|||||||
|
|
||||||
ClientAuthentication(MyProcPort); /* might not return, if failure */
|
ClientAuthentication(MyProcPort); /* might not return, if failure */
|
||||||
|
|
||||||
|
PG_SETMASK(&BlockSig);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Don't want backend to be able to see the postmaster random number
|
* Don't want backend to be able to see the postmaster random number
|
||||||
* generator state. We have to clobber the static random_seed *and*
|
* generator state. We have to clobber the static random_seed *and*
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.230 2001/08/04 00:14:43 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.231 2001/09/07 16:12:48 wieck Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* this is the "main" module of the postgres backend and
|
* this is the "main" module of the postgres backend and
|
||||||
@ -965,6 +965,16 @@ die(SIGNAL_ARGS)
|
|||||||
errno = save_errno;
|
errno = save_errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Shutdown signal from postmaster during client authentication.
|
||||||
|
* Simply exit(0).
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
authdie(SIGNAL_ARGS)
|
||||||
|
{
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Query-cancel signal from postmaster: abort current transaction
|
* Query-cancel signal from postmaster: abort current transaction
|
||||||
* at soonest convenient time
|
* at soonest convenient time
|
||||||
@ -1713,7 +1723,7 @@ PostgresMain(int argc, char *argv[],
|
|||||||
if (!IsUnderPostmaster)
|
if (!IsUnderPostmaster)
|
||||||
{
|
{
|
||||||
puts("\nPOSTGRES backend interactive interface ");
|
puts("\nPOSTGRES backend interactive interface ");
|
||||||
puts("$Revision: 1.230 $ $Date: 2001/08/04 00:14:43 $\n");
|
puts("$Revision: 1.231 $ $Date: 2001/09/07 16:12:48 $\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Id: pqsignal.h,v 1.15 2001/01/24 19:43:25 momjian Exp $
|
* $Id: pqsignal.h,v 1.16 2001/09/07 16:12:49 wieck Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* This shouldn't be in libpq, but the monitor and some other
|
* This shouldn't be in libpq, but the monitor and some other
|
||||||
@ -22,7 +22,8 @@
|
|||||||
|
|
||||||
#ifdef HAVE_SIGPROCMASK
|
#ifdef HAVE_SIGPROCMASK
|
||||||
extern sigset_t UnBlockSig,
|
extern sigset_t UnBlockSig,
|
||||||
BlockSig;
|
BlockSig,
|
||||||
|
AuthBlockSig;
|
||||||
|
|
||||||
#define PG_SETMASK(mask) sigprocmask(SIG_SETMASK, mask, NULL)
|
#define PG_SETMASK(mask) sigprocmask(SIG_SETMASK, mask, NULL)
|
||||||
#else
|
#else
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Id: tcopprot.h,v 1.41 2001/06/08 21:16:48 petere Exp $
|
* $Id: tcopprot.h,v 1.42 2001/09/07 16:12:49 wieck Exp $
|
||||||
*
|
*
|
||||||
* OLD COMMENTS
|
* OLD COMMENTS
|
||||||
* This file was created so that other c files could get the two
|
* This file was created so that other c files could get the two
|
||||||
@ -44,6 +44,7 @@ extern void pg_exec_query_string(char *query_string,
|
|||||||
|
|
||||||
extern void die(SIGNAL_ARGS);
|
extern void die(SIGNAL_ARGS);
|
||||||
extern void quickdie(SIGNAL_ARGS);
|
extern void quickdie(SIGNAL_ARGS);
|
||||||
|
extern void authdie(SIGNAL_ARGS);
|
||||||
extern int PostgresMain(int argc, char *argv[],
|
extern int PostgresMain(int argc, char *argv[],
|
||||||
int real_argc, char *real_argv[], const char *username);
|
int real_argc, char *real_argv[], const char *username);
|
||||||
extern void ResetUsage(void);
|
extern void ResetUsage(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user