Commit b9defe04 authored by Tom Lane's avatar Tom Lane

Marginal code cleanup for streaming replication.

There is no reason that proc.c should have to get involved in this dirty hack
for letting the postmaster know which children are walsenders.  Revert that
file to the way it was, and confine the kluge to pmsignal.c and postmaster.c.
parent e57cd393
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/storage/ipc/pmsignal.c,v 1.30 2010/01/15 09:19:03 heikki Exp $ * $PostgreSQL: pgsql/src/backend/storage/ipc/pmsignal.c,v 1.31 2010/08/23 17:20:01 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "miscadmin.h" #include "miscadmin.h"
#include "postmaster/postmaster.h" #include "postmaster/postmaster.h"
#include "replication/walsender.h"
#include "storage/pmsignal.h" #include "storage/pmsignal.h"
#include "storage/shmem.h" #include "storage/shmem.h"
...@@ -46,8 +47,8 @@ ...@@ -46,8 +47,8 @@
* child processes at random, and postmaster.c is responsible for tracking * child processes at random, and postmaster.c is responsible for tracking
* which one goes with which PID. * which one goes with which PID.
* *
* The fourth state, WALSENDER, is just like ACTIVE, but carries the extra * Actually there is a fourth state, WALSENDER. This is just like ACTIVE,
* information that the child is a WAL sender. * 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_UNUSED 0 /* these values must fit in sig_atomic_t */
...@@ -224,23 +225,8 @@ MarkPostmasterChildActive(void) ...@@ -224,23 +225,8 @@ MarkPostmasterChildActive(void)
Assert(slot > 0 && slot <= PMSignalState->num_child_flags); Assert(slot > 0 && slot <= PMSignalState->num_child_flags);
slot--; slot--;
Assert(PMSignalState->PMChildFlags[slot] == PM_CHILD_ASSIGNED); Assert(PMSignalState->PMChildFlags[slot] == PM_CHILD_ASSIGNED);
PMSignalState->PMChildFlags[slot] = PM_CHILD_ACTIVE; PMSignalState->PMChildFlags[slot] =
} (am_walsender ? PM_CHILD_WALSENDER : PM_CHILD_ACTIVE);
/*
* 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;
} }
/* /*
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/storage/lmgr/proc.c,v 1.221 2010/07/06 19:18:57 momjian Exp $ * $PostgreSQL: pgsql/src/backend/storage/lmgr/proc.c,v 1.222 2010/08/23 17:20:01 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -39,7 +39,6 @@ ...@@ -39,7 +39,6 @@
#include "access/xact.h" #include "access/xact.h"
#include "miscadmin.h" #include "miscadmin.h"
#include "postmaster/autovacuum.h" #include "postmaster/autovacuum.h"
#include "replication/walsender.h"
#include "storage/ipc.h" #include "storage/ipc.h"
#include "storage/lmgr.h" #include "storage/lmgr.h"
#include "storage/pmsignal.h" #include "storage/pmsignal.h"
...@@ -297,12 +296,7 @@ InitProcess(void) ...@@ -297,12 +296,7 @@ InitProcess(void)
* this; it probably should.) * this; it probably should.)
*/ */
if (IsUnderPostmaster && !IsAutoVacuumLauncherProcess()) if (IsUnderPostmaster && !IsAutoVacuumLauncherProcess())
{ MarkPostmasterChildActive();
if (am_walsender)
MarkPostmasterChildWalSender();
else
MarkPostmasterChildActive();
}
/* /*
* Initialize all fields of MyProc, except for the semaphore which was * Initialize all fields of MyProc, except for the semaphore which was
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/storage/pmsignal.h,v 1.32 2010/07/06 19:19:00 momjian Exp $ * $PostgreSQL: pgsql/src/include/storage/pmsignal.h,v 1.33 2010/08/23 17:20:01 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -47,7 +47,6 @@ extern int AssignPostmasterChildSlot(void); ...@@ -47,7 +47,6 @@ extern int AssignPostmasterChildSlot(void);
extern bool ReleasePostmasterChildSlot(int slot); extern bool ReleasePostmasterChildSlot(int slot);
extern bool IsPostmasterChildWalSender(int slot); extern bool IsPostmasterChildWalSender(int slot);
extern void MarkPostmasterChildActive(void); extern void MarkPostmasterChildActive(void);
extern void MarkPostmasterChildWalSender(void);
extern void MarkPostmasterChildInactive(void); extern void MarkPostmasterChildInactive(void);
extern bool PostmasterIsAlive(bool amDirectChild); extern bool PostmasterIsAlive(bool amDirectChild);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment