diff options
Diffstat (limited to 'src/backend/storage/ipc/pmsignal.c')
-rw-r--r-- | src/backend/storage/ipc/pmsignal.c | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/src/backend/storage/ipc/pmsignal.c b/src/backend/storage/ipc/pmsignal.c index 0199c8b577c..2a414a0c2f3 100644 --- a/src/backend/storage/ipc/pmsignal.c +++ b/src/backend/storage/ipc/pmsignal.c @@ -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.29 2010/01/02 16:57:51 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/storage/ipc/pmsignal.c,v 1.30 2010/01/15 09:19:03 heikki Exp $ * *------------------------------------------------------------------------- */ @@ -45,11 +45,15 @@ * process is actively using shared memory. The slots are assigned to * child processes at random, and postmaster.c is responsible for tracking * which one goes with which PID. + * + * The fourth state, WALSENDER, is just like ACTIVE, but carries the extra + * information that the child is a WAL sender. */ #define PM_CHILD_UNUSED 0 /* these values must fit in sig_atomic_t */ #define PM_CHILD_ASSIGNED 1 #define PM_CHILD_ACTIVE 2 +#define PM_CHILD_WALSENDER 3 /* "typedef struct PMSignalData PMSignalData" appears in pmsignal.h */ struct PMSignalData @@ -193,6 +197,22 @@ ReleasePostmasterChildSlot(int slot) } /* + * IsPostmasterChildWalSender - check if given slot is in use by a + * walsender process. + */ +bool +IsPostmasterChildWalSender(int slot) +{ + Assert(slot > 0 && slot <= PMSignalState->num_child_flags); + slot--; + + if (PMSignalState->PMChildFlags[slot] == PM_CHILD_WALSENDER) + return true; + else + return false; +} + +/* * MarkPostmasterChildActive - mark a postmaster child as about to begin * actively using shared memory. This is called in the child process. */ @@ -208,6 +228,22 @@ MarkPostmasterChildActive(void) } /* + * MarkPostmasterChildWalSender - like MarkPostmasterChildActive(), but + * marks the postmaster child as a WAL sender instead of a regular backend. + * This is called in the child process. + */ +void +MarkPostmasterChildWalSender(void) +{ + int slot = MyPMChildSlot; + + Assert(slot > 0 && slot <= PMSignalState->num_child_flags); + slot--; + Assert(PMSignalState->PMChildFlags[slot] == PM_CHILD_ASSIGNED); + PMSignalState->PMChildFlags[slot] = PM_CHILD_WALSENDER; +} + +/* * MarkPostmasterChildInactive - mark a postmaster child as done using * shared memory. This is called in the child process. */ @@ -218,7 +254,8 @@ MarkPostmasterChildInactive(void) Assert(slot > 0 && slot <= PMSignalState->num_child_flags); slot--; - Assert(PMSignalState->PMChildFlags[slot] == PM_CHILD_ACTIVE); + Assert(PMSignalState->PMChildFlags[slot] == PM_CHILD_ACTIVE || + PMSignalState->PMChildFlags[slot] == PM_CHILD_WALSENDER); PMSignalState->PMChildFlags[slot] = PM_CHILD_ASSIGNED; } |