1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-10 17:42:29 +03:00

Separate out bgwriter code into a logically separate module, rather

than being random pieces of other files.  Give bgwriter responsibility
for all checkpoint activity (other than a post-recovery checkpoint);
so this child process absorbs the functionality of the former transient
checkpoint and shutdown subprocesses.  While at it, create an actual
include file for postmaster.c, which for some reason never had its own
file before.
This commit is contained in:
Tom Lane
2004-05-29 22:48:23 +00:00
parent d531fd2cdc
commit 076a055acf
28 changed files with 1133 additions and 902 deletions

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/storage/ipc/ipci.c,v 1.67 2004/05/28 05:13:03 tgl Exp $
* $PostgreSQL: pgsql/src/backend/storage/ipc/ipci.c,v 1.68 2004/05/29 22:48:20 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -18,6 +18,7 @@
#include "miscadmin.h"
#include "access/clog.h"
#include "access/xlog.h"
#include "postmaster/bgwriter.h"
#include "storage/bufmgr.h"
#include "storage/freespace.h"
#include "storage/ipc.h"
@@ -72,6 +73,7 @@ CreateSharedMemoryAndSemaphores(bool makePrivate,
size += LWLockShmemSize();
size += SInvalShmemSize(maxBackends);
size += FreeSpaceShmemSize();
size += BgWriterShmemSize();
#ifdef EXEC_BACKEND
size += ShmemBackendArraySize();
#endif
@@ -155,9 +157,10 @@ CreateSharedMemoryAndSemaphores(bool makePrivate,
InitFreeSpaceMap();
/*
* Set up child-to-postmaster signaling mechanism
* Set up interprocess signaling mechanisms
*/
PMSignalInit();
BgWriterShmemInit();
#ifdef EXEC_BACKEND
/*

View File

@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/storage/ipc/pmsignal.c,v 1.13 2004/02/08 22:28:56 neilc Exp $
* $PostgreSQL: pgsql/src/backend/storage/ipc/pmsignal.c,v 1.14 2004/05/29 22:48:20 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -83,3 +83,41 @@ CheckPostmasterSignal(PMSignalReason reason)
}
return false;
}
/*
* PostmasterIsAlive - check whether postmaster process is still alive
*
* amDirectChild should be passed as "true" by code that knows it is
* executing in a direct child process of the postmaster; pass "false"
* if an indirect child or not sure. The "true" case uses a faster and
* more reliable test, so use it when possible.
*/
bool
PostmasterIsAlive(bool amDirectChild)
{
#ifndef WIN32
if (amDirectChild)
{
/*
* If the postmaster is alive, we'll still be its child. If it's
* died, we'll be reassigned as a child of the init process.
*/
return (getppid() == PostmasterPid);
}
else
{
/*
* Use kill() to see if the postmaster is still alive. This can
* sometimes give a false positive result, since the postmaster's PID
* may get recycled, but it is good enough for existing uses by
* indirect children.
*/
return (kill(PostmasterPid, 0) == 0);
}
#else /* WIN32 */
/*
* XXX needs to be implemented by somebody
*/
return true;
#endif /* WIN32 */
}