1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-25 13:17:41 +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:
Andres Freund
2015-01-13 13:12:37 +01:00
parent 2be82dcf17
commit 31c453165b
15 changed files with 96 additions and 274 deletions

View File

@@ -22,7 +22,6 @@
#include <fcntl.h>
#include <limits.h>
#include <signal.h>
#include <time.h>
#include <unistd.h>
#include <sys/socket.h>
#ifdef HAVE_SYS_SELECT_H
@@ -3536,30 +3535,12 @@ PostgresMain(int argc, char *argv[],
sigjmp_buf local_sigjmp_buf;
volatile bool send_ready_for_query = true;
/*
* Initialize globals (already done if under postmaster, but not if
* standalone).
*/
/* Initialize startup process environment if necessary. */
if (!IsUnderPostmaster)
{
MyProcPid = getpid();
MyStartTime = time(NULL);
}
InitStandaloneProcess(argv[0]);
SetProcessingMode(InitProcessing);
/* Compute paths, if we didn't inherit them from postmaster */
if (my_exec_path[0] == '\0')
{
if (find_my_exec(argv[0], my_exec_path) < 0)
elog(FATAL, "%s: could not locate my own executable path",
argv[0]);
}
if (pkglib_path[0] == '\0')
get_pkglib_path(my_exec_path, pkglib_path);
/*
* Set default values for command-line options.
*/
@@ -3589,11 +3570,6 @@ PostgresMain(int argc, char *argv[],
proc_exit(1);
}
/*
* You might expect to see a setsid() call here, but it's not needed,
* because if we are under a postmaster then BackendInitialize() did it.
*/
/*
* Set up signal handlers and masks.
*