3737 *
3838 *
3939 * IDENTIFICATION
40- * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.318 2003/05/02 22:01:51 momjian Exp $
40+ * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.319 2003/05/02 22:02:47 momjian Exp $
4141 *
4242 * NOTES
4343 *
@@ -256,11 +256,12 @@ static void dummy_handler(SIGNAL_ARGS);
256256static void CleanupProc (int pid ,int exitstatus );
257257static void LogChildExit (int lev ,const char * procname ,
258258int pid ,int exitstatus );
259- static int DoBackend (Port * port );
259+ static int BackendFinalize (Port * port );
260260void ExitPostmaster (int status );
261261static void usage (const char * );
262262static int ServerLoop (void );
263263static int BackendStartup (Port * port );
264+ static void BackendFork (Port * port ,Backend * bn );
264265static int ProcessStartupPacket (Port * port ,bool SSLdone );
265266static void processCancelRequest (Port * port ,void * pkt );
266267static int initMasks (fd_set * rmask ,fd_set * wmask );
@@ -570,6 +571,9 @@ PostmasterMain(int argc, char *argv[])
570571SetDataDir (potential_DataDir );
571572
572573ProcessConfigFile (PGC_POSTMASTER );
574+ #ifdef EXEC_BACKEND
575+ write_nondefault_variables (PGC_POSTMASTER );
576+ #endif
573577
574578/*
575579 * Check for invalid combinations of GUC settings.
@@ -1231,7 +1235,7 @@ ProcessStartupPacket(Port *port, bool SSLdone)
12311235 * Now fetch parameters out of startup packet and save them into the
12321236 * Port structure. All data structures attached to the Port struct
12331237 * must be allocated in TopMemoryContext so that they won't disappear
1234- * when we pass them to PostgresMain (seeDoBackend ). We need not worry
1238+ * when we pass them to PostgresMain (seeBackendFinalize ). We need not worry
12351239 * about leaking this storage on failure, since we aren't in the postmaster
12361240 * process anymore.
12371241 */
@@ -1568,6 +1572,9 @@ SIGHUP_handler(SIGNAL_ARGS)
15681572elog (LOG ,"Received SIGHUP, reloading configuration files" );
15691573SignalChildren (SIGHUP );
15701574ProcessConfigFile (PGC_SIGHUP );
1575+ #ifdef EXEC_BACKEND
1576+ write_nondefault_variables (PGC_SIGHUP );
1577+ #endif
15711578load_hba ();
15721579load_ident ();
15731580}
@@ -2053,28 +2060,7 @@ BackendStartup(Port *port)
20532060pid = fork ();
20542061
20552062if (pid == 0 )/* child */
2056- {
2057- int status ;
2058-
2059- #ifdef LINUX_PROFILE
2060- setitimer (ITIMER_PROF ,& prof_itimer ,NULL );
2061- #endif
2062-
2063- #ifdef __BEOS__
2064- /* Specific beos backend startup actions */
2065- beos_backend_startup ();
2066- #endif
2067- free (bn );
2068-
2069- status = DoBackend (port );
2070- if (status != 0 )
2071- {
2072- elog (LOG ,"connection startup failed" );
2073- proc_exit (status );
2074- }
2075- else
2076- proc_exit (0 );
2077- }
2063+ BackendFork (port ,bn );/* never returns */
20782064
20792065/* in parent, error */
20802066if (pid < 0 )
@@ -2108,6 +2094,31 @@ BackendStartup(Port *port)
21082094}
21092095
21102096
2097+ static void
2098+ BackendFork (Port * port ,Backend * bn )
2099+ {
2100+ int status ;
2101+
2102+ #ifdef LINUX_PROFILE
2103+ setitimer (ITIMER_PROF ,& prof_itimer ,NULL );
2104+ #endif
2105+
2106+ #ifdef __BEOS__
2107+ /* Specific beos backend startup actions */
2108+ beos_backend_startup ();
2109+ #endif
2110+ free (bn );
2111+
2112+ status = BackendFinalize (port );
2113+ if (status != 0 )
2114+ {
2115+ elog (LOG ,"connection startup failed" );
2116+ proc_exit (status );
2117+ }
2118+ else
2119+ proc_exit (0 );
2120+ }
2121+
21112122/*
21122123 * Try to report backend fork() failure to client before we close the
21132124 * connection.Since we do not care to risk blocking the postmaster on
@@ -2173,7 +2184,7 @@ split_opts(char **argv, int *argcp, char *s)
21732184}
21742185
21752186/*
2176- *DoBackend -- perform authentication, and if successful, set up the
2187+ *BackendFinalize -- perform authentication, and if successful, set up the
21772188 *backend's argument list and invoke backend main().
21782189 *
21792190 * This used to perform an execv() but we no longer exec the backend;
@@ -2184,7 +2195,7 @@ split_opts(char **argv, int *argcp, char *s)
21842195 *If PostgresMain() fails, return status.
21852196 */
21862197static int
2187- DoBackend (Port * port )
2198+ BackendFinalize (Port * port )
21882199{
21892200char * remote_host ;
21902201char * * av ;
@@ -2221,6 +2232,10 @@ DoBackend(Port *port)
22212232/* Reset MyProcPid to new backend's pid */
22222233MyProcPid = getpid ();
22232234
2235+ #ifdef EXEC_BACKEND
2236+ read_nondefault_variables ();
2237+ #endif
2238+
22242239/*
22252240 * Initialize libpq and enable reporting of elog errors to the client.
22262241 * Must do this now because authentication uses libpq to send
@@ -2248,7 +2263,7 @@ DoBackend(Port *port)
22482263unsigned short remote_port ;
22492264char * host_addr ;
22502265#ifdef HAVE_IPV6
2251- char ip_hostinfo [INET6_ADDRSTRLEN ];
2266+ char ip_hostinfo [INET6_ADDRSTRLEN ];
22522267#else
22532268char ip_hostinfo [INET_ADDRSTRLEN ];
22542269#endif
@@ -2294,7 +2309,7 @@ DoBackend(Port *port)
22942309}
22952310else
22962311{
2297- /* not AF_INET */
2312+ /* not AF_INET */
22982313remote_host = "[local]" ;
22992314
23002315if (Log_connections )
@@ -2318,7 +2333,7 @@ DoBackend(Port *port)
23182333 * indefinitely. PreAuthDelay doesn't count against the time limit.
23192334 */
23202335if (!enable_sig_alarm (AuthenticationTimeout * 1000 , false))
2321- elog (FATAL ,"DoBackend : Unable to set timer for auth timeout" );
2336+ elog (FATAL ,"BackendFinalize : Unable to set timer for auth timeout" );
23222337
23232338/*
23242339 * Receive the startup packet (which might turn out to be a cancel
@@ -2347,7 +2362,7 @@ DoBackend(Port *port)
23472362 * SIGTERM/SIGQUIT again until backend startup is complete.
23482363 */
23492364if (!disable_sig_alarm (false))
2350- elog (FATAL ,"DoBackend : Unable to disable timer for auth timeout" );
2365+ elog (FATAL ,"BackendFinalize : Unable to disable timer for auth timeout" );
23512366PG_SETMASK (& BlockSig );
23522367
23532368if (Log_connections )