mirror of
https://github.com/postgres/postgres.git
synced 2025-07-03 20:02:46 +03:00
Commonalize process startup code.
Move common code, that was duplicated in every postmaster child/every standalone process, into two functions in miscinit.c. Not only does that already result in a fair amount of net code reduction but it also makes it much easier to remove more duplication in the future. The prime motivation wasn't code deduplication though, but easier addition of new common code.
This commit is contained in:
@ -164,11 +164,6 @@ SysLoggerMain(int argc, char *argv[])
|
||||
int currentLogRotationAge;
|
||||
pg_time_t now;
|
||||
|
||||
IsUnderPostmaster = true; /* we are a postmaster subprocess now */
|
||||
|
||||
MyProcPid = getpid(); /* reset MyProcPid */
|
||||
|
||||
MyStartTime = time(NULL); /* set our start time in case we call elog */
|
||||
now = MyStartTime;
|
||||
|
||||
#ifdef EXEC_BACKEND
|
||||
@ -236,18 +231,8 @@ SysLoggerMain(int argc, char *argv[])
|
||||
syslogPipe[1] = 0;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If possible, make this process a group leader, so that the postmaster
|
||||
* can signal any child processes too. (syslogger probably never has any
|
||||
* child processes, but for consistency we make all postmaster child
|
||||
* processes do this.)
|
||||
*/
|
||||
#ifdef HAVE_SETSID
|
||||
if (setsid() < 0)
|
||||
elog(FATAL, "setsid() failed: %m");
|
||||
#endif
|
||||
InitializeLatchSupport(); /* needed for latch waits */
|
||||
|
||||
InitializeLatchSupport(); /* needed for latch waits */
|
||||
|
||||
/* Initialize private latch for use by signal handlers */
|
||||
InitLatch(&sysLoggerLatch);
|
||||
@ -609,12 +594,11 @@ SysLogger_Start(void)
|
||||
#ifndef EXEC_BACKEND
|
||||
case 0:
|
||||
/* in postmaster child ... */
|
||||
InitPostmasterChild();
|
||||
|
||||
/* Close the postmaster's sockets */
|
||||
ClosePostmasterPorts(true);
|
||||
|
||||
/* Lose the postmaster's on-exit routines */
|
||||
on_exit_reset();
|
||||
|
||||
/* Drop our connection to postmaster's shared memory, as well */
|
||||
dsm_detach_all();
|
||||
PGSharedMemoryDetach();
|
||||
|
Reference in New Issue
Block a user