1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-14 18:42:34 +03:00

Exit backend from SIGTERM or FATAL by simulating client EOF, rather than

calling proc_exit() directly.  This should make SIGTERM more reliable.
This commit is contained in:
Bruce Momjian
2004-04-11 00:54:45 +00:00
parent 1934055cbe
commit 3c4ab3f51d
3 changed files with 18 additions and 6 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.398 2004/04/07 05:05:49 momjian Exp $
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.399 2004/04/11 00:54:44 momjian Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
@ -2938,7 +2938,10 @@ PostgresMain(int argc, char *argv[], const char *username)
/*
* (3) read a command (loop blocks here)
*/
firstchar = ReadCommand(&input_message);
if (!in_fatal_exit)
firstchar = ReadCommand(&input_message);
else
firstchar = EOF;
/*
* (4) disable async signal conditions again.
@ -3170,7 +3173,8 @@ PostgresMain(int argc, char *argv[], const char *username)
* Otherwise it will fail to be called during other
* backend-shutdown scenarios.
*/
proc_exit(0);
proc_exit(!in_fatal_exit ? 0 : proc_exit_inprogress ||
!IsUnderPostmaster);
case 'd': /* copy data */
case 'c': /* copy done */