From e8f1097361d9d2012c751d7e66cd4dd1b6d26ac6 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 5 Aug 2001 02:06:50 +0000 Subject: Endeavor to make pgstats buffer process (a) safe and (b) useful. Make sure it exits immediately when collector process dies --- in old code, buffer process would hang around and compete with the new buffer process for packets. Make sure it doesn't block on writing the pipe when the collector falls more than a pipeload behind. Avoid leaking pgstats FDs into every backend. --- src/backend/postmaster/postmaster.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/backend/postmaster/postmaster.c') diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index 511f9bc0ee6..c3036630bc5 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -37,7 +37,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.234 2001/08/04 00:14:43 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.235 2001/08/05 02:06:50 tgl Exp $ * * NOTES * @@ -227,7 +227,6 @@ extern int optreset; static void pmdaemonize(int argc, char *argv[]); static Port *ConnCreate(int serverFd); static void ConnFree(Port *port); -static void ClosePostmasterPorts(void); static void reset_shared(unsigned short port); static void SIGHUP_handler(SIGNAL_ARGS); static void pmdie(SIGNAL_ARGS); @@ -1241,8 +1240,8 @@ ConnFree(Port *conn) * that are not needed by that child process. The postmaster still has * them open, of course. */ -static void -ClosePostmasterPorts(void) +void +ClosePostmasterPorts(bool pgstat_too) { /* Close the listen sockets */ if (NetServer) @@ -1252,6 +1251,9 @@ ClosePostmasterPorts(void) StreamClose(ServerSock_UNIX); ServerSock_UNIX = INVALID_SOCK; #endif + /* Close pgstat control sockets, unless we're starting pgstat itself */ + if (pgstat_too) + pgstat_close_sockets(); } @@ -1900,7 +1902,7 @@ DoBackend(Port *port) */ /* Close the postmaster's other sockets */ - ClosePostmasterPorts(); + ClosePostmasterPorts(true); /* Save port etc. for ps status */ MyProcPort = port; @@ -2224,7 +2226,7 @@ SSDataBase(int xlop) on_exit_reset(); /* Close the postmaster's sockets */ - ClosePostmasterPorts(); + ClosePostmasterPorts(true); /* Set up command-line arguments for subprocess */ av[ac++] = "postgres"; -- cgit v1.2.3