LogicalRepCtxStruct *LogicalRepCtx;
+static void ApplyLauncherWakeup(void);
+static void logicalrep_launcher_onexit(int code, Datum arg);
static void logicalrep_worker_onexit(int code, Datum arg);
static void logicalrep_worker_detach(void);
LWLockRelease(LogicalRepWorkerLock);
}
+/*
+ * Cleanup function for logical replication launcher.
+ *
+ * Called on logical replication launcher exit.
+ */
+static void
+logicalrep_launcher_onexit(int code, Datum arg)
+{
+ LogicalRepCtx->launcher_pid = 0;
+}
+
/*
* Cleanup function.
*
on_commit_launcher_wakeup = true;
}
-void
+static void
ApplyLauncherWakeup(void)
{
- if (IsBackendPid(LogicalRepCtx->launcher_pid))
+ if (LogicalRepCtx->launcher_pid != 0)
kill(LogicalRepCtx->launcher_pid, SIGUSR1);
}
ereport(DEBUG1,
(errmsg("logical replication launcher started")));
+ before_shmem_exit(logicalrep_launcher_onexit, (Datum) 0);
+
/* Establish signal handlers. */
pqsignal(SIGHUP, logicalrep_worker_sighup);
pqsignal(SIGTERM, logicalrep_worker_sigterm);
extern Size ApplyLauncherShmemSize(void);
extern void ApplyLauncherShmemInit(void);
-extern void ApplyLauncherWakeup(void);
extern void ApplyLauncherWakeupAtCommit(void);
extern void AtCommit_ApplyLauncher(void);