diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2000-12-20 21:51:52 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2000-12-20 21:51:52 +0000 |
commit | 39b547f43006938e93bd781ccef6f8c3610b9509 (patch) | |
tree | c7f8bc6e6742ee976b3a1ccface127611c6e3c3e /src/backend/tcop/postgres.c | |
parent | e4d97cb70efddfc07b79cc4d8490da9132cf9b26 (diff) | |
download | postgresql-39b547f43006938e93bd781ccef6f8c3610b9509.tar.gz postgresql-39b547f43006938e93bd781ccef6f8c3610b9509.zip |
Prevent freshly-started backend from ignoring SIGUSR1, per race condition
observed by Inoue. Also, don't call ProcRemove() from postmaster if we
have detected a backend crash --- too risky if shared memory is corrupted.
It's not needed anyway, considering we are going to reinitialize shared
memory and semaphores as soon as the last child is dead.
Diffstat (limited to 'src/backend/tcop/postgres.c')
-rw-r--r-- | src/backend/tcop/postgres.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 2946c9a5ef4..a8b7b4ec1bc 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.197 2000/12/18 18:45:05 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.198 2000/12/20 21:51:52 tgl Exp $ * * NOTES * this is the "main" module of the postgres backend and @@ -1462,21 +1462,12 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha Assert(DataDir); /* - * 1. Set BlockSig and UnBlockSig masks. 2. Set up signal handlers. 3. - * Allow only SIGUSR1 signal (we never block it) during - * initialization. + * Set up signal handlers and masks. * - * Note that postmaster already blocked ALL signals to make us happy. + * Note that postmaster blocked all signals before forking child process, + * so there is no race condition whereby we might receive a signal before + * we have set up the handler. */ - pqinitmask(); - -#ifdef HAVE_SIGPROCMASK - sigdelset(&BlockSig, SIGUSR1); -#else - BlockSig &= ~(sigmask(SIGUSR1)); -#endif - - PG_SETMASK(&BlockSig); /* block everything except SIGUSR1 */ pqsignal(SIGHUP, SigHupHandler); /* set flag to read config file */ pqsignal(SIGINT, QueryCancelHandler); /* cancel current query */ @@ -1499,6 +1490,17 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha pqsignal(SIGTTOU, SIG_DFL); pqsignal(SIGCONT, SIG_DFL); + pqinitmask(); + + /* We allow SIGUSR1 (quickdie) at all times */ +#ifdef HAVE_SIGPROCMASK + sigdelset(&BlockSig, SIGUSR1); +#else + BlockSig &= ~(sigmask(SIGUSR1)); +#endif + + PG_SETMASK(&BlockSig); /* block everything except SIGUSR1 */ + if (IsUnderPostmaster) { @@ -1649,7 +1651,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha if (!IsUnderPostmaster) { puts("\nPOSTGRES backend interactive interface "); - puts("$Revision: 1.197 $ $Date: 2000/12/18 18:45:05 $\n"); + puts("$Revision: 1.198 $ $Date: 2000/12/20 21:51:52 $\n"); } /* |