Index: src/backend/bootstrap/bootstrap.c =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/backend/bootstrap/bootstrap.c,v retrieving revision 1.172 diff -c -r1.172 bootstrap.c *** src/backend/bootstrap/bootstrap.c 25 Dec 2003 03:52:50 -0000 1.172 --- src/backend/bootstrap/bootstrap.c 26 Dec 2003 06:44:45 -0000 *************** *** 51,57 **** #ifdef EXEC_BACKEND typedef struct Port Port; extern void SSDataBaseInit(int); ! extern void read_backend_variables(pid_t, Port*); #endif extern int Int_yyparse(void); --- 51,57 ---- #ifdef EXEC_BACKEND typedef struct Port Port; extern void SSDataBaseInit(int); ! extern void read_backend_variables(unsigned long, Port*); #endif extern int Int_yyparse(void); *************** *** 231,236 **** --- 231,239 ---- int flag; int xlogop = BS_XLOG_NOP; char *potential_DataDir = NULL; + #ifdef EXEC_BACKEND + unsigned long backendID = 0; + #endif /* * initialize globals *************** *** 291,300 **** break; case 'p': #ifdef EXEC_BACKEND ! IsUnderPostmaster = true; #endif dbname = strdup(optarg); ! break; case 'B': SetConfigOption("shared_buffers", optarg, PGC_POSTMASTER, PGC_S_ARGV); break; --- 294,308 ---- break; case 'p': #ifdef EXEC_BACKEND ! { ! char buf[MAXPGPATH]; ! IsUnderPostmaster = true; ! sscanf(optarg,"%lu,%s",&backendID,buf); ! dbname = strdup(buf); ! } #endif dbname = strdup(optarg); ! break; case 'B': SetConfigOption("shared_buffers", optarg, PGC_POSTMASTER, PGC_S_ARGV); break; *************** *** 363,369 **** { #ifdef EXEC_BACKEND read_nondefault_variables(); ! read_backend_variables(getpid(),NULL); SSDataBaseInit(xlogop); #endif --- 371,377 ---- { #ifdef EXEC_BACKEND read_nondefault_variables(); ! read_backend_variables(backendID,NULL); SSDataBaseInit(xlogop); #endif *************** *** 431,441 **** switch (xlogop) { case BS_XLOG_BGWRITER: ! InitDummyProcess(DUMMY_PROC_BGWRITER); break; ! default: ! InitDummyProcess(DUMMY_PROC_DEFAULT); break; } } --- 439,449 ---- switch (xlogop) { case BS_XLOG_BGWRITER: ! InitDummyProcess(DUMMY_PROC_BGWRITER); break; ! default: ! InitDummyProcess(DUMMY_PROC_DEFAULT); break; } } Index: src/backend/postmaster/pgstat.c =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/backend/postmaster/pgstat.c,v retrieving revision 1.50 diff -c -r1.50 pgstat.c *** src/backend/postmaster/pgstat.c 25 Dec 2003 03:52:51 -0000 1.50 --- src/backend/postmaster/pgstat.c 26 Dec 2003 06:44:47 -0000 *************** *** 107,113 **** * ---------- */ #ifdef EXEC_BACKEND ! static void pgstat_exec(STATS_PROCESS_TYPE procType); static void pgstat_parseArgs(PGSTAT_FORK_ARGS); #endif NON_EXEC_STATIC void pgstat_main(PGSTAT_FORK_ARGS); --- 107,113 ---- * ---------- */ #ifdef EXEC_BACKEND ! static pid_t pgstat_forkexec(STATS_PROCESS_TYPE procType); static void pgstat_parseArgs(PGSTAT_FORK_ARGS); #endif NON_EXEC_STATIC void pgstat_main(PGSTAT_FORK_ARGS); *************** *** 337,351 **** #ifdef EXEC_BACKEND /* ---------- ! * pgstat_exec() - * ! * Used to format up the arglist for, and exec, statistics * (buffer and collector) processes * */ ! static void ! pgstat_exec(STATS_PROCESS_TYPE procType) { char *av[11]; int ac = 0, bufc = 0, i; char pgstatBuf[8][MAXPGPATH]; --- 337,352 ---- #ifdef EXEC_BACKEND /* ---------- ! * pgstat_forkexec() - * ! * Used to format up the arglist for, then fork and exec, statistics * (buffer and collector) processes * */ ! static pid_t ! pgstat_forkexec(STATS_PROCESS_TYPE procType) { + pid_t pid; char *av[11]; int ac = 0, bufc = 0, i; char pgstatBuf[8][MAXPGPATH]; *************** *** 384,395 **** for (i = 0; i < bufc; i++) av[ac++] = pgstatBuf[i]; ! av[ac++] = NULL; ! Assert(ac <= lengthof(av)); ! if (execv(pg_pathname,av) == -1) /* FIXME: [fork/exec] suggestions for what to do here? Can't call elog... */ ! Assert(false); } --- 385,399 ---- for (i = 0; i < bufc; i++) av[ac++] = pgstatBuf[i]; ! av[ac++] = NULL; ! Assert(ac <= lengthof(av)); ! /* Fire off execv in child */ ! if ((pid = fork()) == 0 && (execv(pg_pathname,av) == -1)) /* FIXME: [fork/exec] suggestions for what to do here? Can't call elog... */ ! abort(); ! ! return pid; /* Parent returns pid */ } *************** *** 479,485 **** --- 483,493 ---- beos_before_backend_startup(); #endif + #ifdef EXEC_BACKEND + switch ((pgStatSock = (int) pgstat_forkexec(STAT_PROC_BUFFER))) + #else switch ((pgStatPid = (int) fork())) + #endif { case -1: #ifdef __BEOS__ *************** *** 490,521 **** (errmsg("could not fork statistics buffer: %m"))); return; case 0: break; default: pgstat_is_running = true; return; } - - /* in postmaster child ... */ - - #ifdef __BEOS__ - /* Specific beos actions after backend startup */ - beos_backend_startup(); - #endif - - /* Close the postmaster's sockets, except for pgstat link */ - ClosePostmasterPorts(false); - - /* Drop our connection to postmaster's shared memory, as well */ - PGSharedMemoryDetach(); - - #ifdef EXEC_BACKEND - pgstat_exec(STAT_PROC_BUFFER); - #else - pgstat_main(); - #endif } --- 498,524 ---- (errmsg("could not fork statistics buffer: %m"))); return; + #ifndef EXEC_BACKEND case 0: + /* in postmaster child ... */ + #ifdef __BEOS__ + /* Specific beos actions after backend startup */ + beos_backend_startup(); + #endif + /* Close the postmaster's sockets, except for pgstat link */ + ClosePostmasterPorts(false); + + /* Drop our connection to postmaster's shared memory, as well */ + PGSharedMemoryDetach(); + + pgstat_main(); break; + #endif default: pgstat_is_running = true; return; } } *************** *** 1385,1412 **** exit(1); } switch (fork()) { case -1: ereport(LOG, (errmsg("could not fork statistics collector: %m"))); exit(1); case 0: /* child becomes collector process */ - #ifdef EXEC_BACKEND - pgstat_exec(STAT_PROC_COLLECTOR); - #else pgstat_mainChild(); #endif - exit(0); default: /* parent becomes buffer process */ closesocket(pgStatPipe[0]); pgstat_recvbuffer(); - exit(0); } } --- 1388,1418 ---- exit(1); } + #ifdef EXEC_BACKEND + /* child becomes collector process */ + switch (pgstat_forkexec(STAT_PROC_COLLECTOR)) + #else switch (fork()) + #endif { case -1: ereport(LOG, (errmsg("could not fork statistics collector: %m"))); exit(1); + #ifndef EXEC_BACKEND case 0: /* child becomes collector process */ pgstat_mainChild(); + break; #endif default: /* parent becomes buffer process */ closesocket(pgStatPipe[0]); pgstat_recvbuffer(); } + exit(0); } Index: src/backend/postmaster/postmaster.c =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/backend/postmaster/postmaster.c,v retrieving revision 1.353 diff -c -r1.353 postmaster.c *** src/backend/postmaster/postmaster.c 25 Dec 2003 03:52:51 -0000 1.353 --- src/backend/postmaster/postmaster.c 26 Dec 2003 06:44:50 -0000 *************** *** 297,304 **** __attribute__((format(printf, 1, 2))); #ifdef EXEC_BACKEND ! void read_backend_variables(pid_t pid, Port *port); ! static void write_backend_variables(pid_t pid, Port *port); #endif #define StartupDataBase() SSDataBase(BS_XLOG_STARTUP) --- 297,305 ---- __attribute__((format(printf, 1, 2))); #ifdef EXEC_BACKEND ! void read_backend_variables(unsigned long id, Port *port); ! static unsigned long tmpBackendFileNum = 0; ! static bool write_backend_variables(Port *port); #endif #define StartupDataBase() SSDataBase(BS_XLOG_STARTUP) *************** *** 916,922 **** #endif #ifdef LINUX_PROFILE ! /* see comments in BackendStartup */ getitimer(ITIMER_PROF, &prof_itimer); #endif --- 917,923 ---- #endif #ifdef LINUX_PROFILE ! /* see comments in BackendFork */ getitimer(ITIMER_PROF, &prof_itimer); #endif *************** *** 2183,2192 **** Backend *bn; /* for backend cleanup */ pid_t pid; - #ifdef LINUX_PROFILE - struct itimerval prof_itimer; - #endif - /* * Compute the cancel key that will be assigned to this backend. The * backend will have its own copy in the forked-off process' value of --- 2184,2189 ---- *************** *** 2218,2263 **** fflush(stdout); fflush(stderr); - #ifdef LINUX_PROFILE - - /* - * Linux's fork() resets the profiling timer in the child process. If - * we want to profile child processes then we need to save and restore - * the timer setting. This is a waste of time if not profiling, - * however, so only do it if commanded by specific -DLINUX_PROFILE - * switch. - */ - getitimer(ITIMER_PROF, &prof_itimer); - #endif - #ifdef __BEOS__ /* Specific beos actions before backend startup */ beos_before_backend_startup(); #endif ! pid = fork(); ! ! if (pid == 0) /* child */ ! { ! int status; ! ! #ifdef LINUX_PROFILE ! setitimer(ITIMER_PROF, &prof_itimer, NULL); ! #endif ! ! #ifdef __BEOS__ ! /* Specific beos backend startup actions */ ! beos_backend_startup(); ! #endif ! free(bn); ! status = BackendFork(port); ! ! if (status != 0) ! ereport(LOG, ! (errmsg("connection startup failed"))); ! proc_exit(status); ! } /* in parent, error */ if (pid < 0) --- 2215,2233 ---- fflush(stdout); fflush(stderr); #ifdef __BEOS__ /* Specific beos actions before backend startup */ beos_before_backend_startup(); #endif ! /* ! * FIXME: [fork/exec] This mechanism means that the bn struct in the ! * child is never freed. Doesn't seem like a substantial loss... ! */ ! pid = BackendFork(port); ! if (pid == 0) ! Assert(false); /* child never gets here */ /* in parent, error */ if (pid < 0) *************** *** 2349,2358 **** /* ! * BackendInit/Fork -- perform authentication [BackendInit], and if successful, * set up the backend's argument list [BackendFork] and invoke * backend main() [or exec in EXEC_BACKEND case] * * returns: * Shouldn't return at all. * If PostgresMain() fails, return status. --- 2319,2331 ---- /* ! * BackendInit/Fork -- fork, perform authentication [BackendInit], and if successful, * set up the backend's argument list [BackendFork] and invoke * backend main() [or exec in EXEC_BACKEND case] * + * note: in the EXEC_BACKEND case, we delay the fork until argument list has been + * established + * * returns: * Shouldn't return at all. * If PostgresMain() fails, return status. *************** *** 2492,2498 **** } ! static int BackendFork(Port *port) { char **av; --- 2465,2471 ---- } ! static pid_t BackendFork(Port *port) { char **av; *************** *** 2501,2510 **** --- 2474,2515 ---- char debugbuf[32]; #ifndef EXEC_BACKEND char protobuf[32]; + #ifdef LINUX_PROFILE + struct itimerval prof_itimer; #endif + #else + char idbuf[32]; + #endif + pid_t pid; int i; char tmpExtraOptions[MAXPGPATH]; + #ifndef EXEC_BACKEND + #ifdef LINUX_PROFILE + /* + * Linux's fork() resets the profiling timer in the child process. If + * we want to profile child processes then we need to save and restore + * the timer setting. This is a waste of time if not profiling, + * however, so only do it if commanded by specific -DLINUX_PROFILE + * switch. + */ + getitimer(ITIMER_PROF, &prof_itimer); + #endif + + /* Non EXEC_BACKEND case; fork here */ + if ((pid = fork()) != 0) + return pid; + + /* in child */ + + #ifdef LINUX_PROFILE + setitimer(ITIMER_PROF, &prof_itimer, NULL); + #endif + + #ifdef __BEOS__ + /* Specific beos backend startup actions */ + beos_backend_startup(); + #endif /* * Let's clean up ourselves as the postmaster child, and * close the postmaster's other sockets *************** *** 2520,2531 **** */ if (PreAuthDelay > 0) sleep(PreAuthDelay); port->canAcceptConnections = canAcceptConnections(); #ifndef EXEC_BACKEND if (!BackendInit(port)) ! return -1; #endif /* ---------------- --- 2525,2545 ---- */ if (PreAuthDelay > 0) sleep(PreAuthDelay); + #endif + /* Finalize the port struct for connection */ port->canAcceptConnections = canAcceptConnections(); #ifndef EXEC_BACKEND if (!BackendInit(port)) ! { ! ereport(LOG, ! (errmsg("connection startup failed"))); ! proc_exit(1); ! } ! #else ! if (!write_backend_variables(port)) ! return -1; /* log issued by write_backend_variables */ #endif /* ---------------- *************** *** 2540,2546 **** * split_opts(). * ---------------- */ ! maxac = 10; /* for fixed args supplied below */ maxac += (strlen(ExtraOptions) + 1) / 2; if (port->cmdline_options) maxac += (strlen(port->cmdline_options) + 1) / 2; --- 2554,2560 ---- * split_opts(). * ---------------- */ ! maxac = 12; /* for fixed args supplied below */ maxac += (strlen(ExtraOptions) + 1) / 2; if (port->cmdline_options) maxac += (strlen(port->cmdline_options) + 1) / 2; *************** *** 2579,2597 **** * database to use. -p marks the end of secure switches. */ #ifdef EXEC_BACKEND - write_backend_variables(getpid(),port); /* pass data dir before end of secure switches (-p) */ av[ac++] = "-D"; av[ac++] = DataDir; ! /* ! * This is totally bogus. We need to pass an arg to -p, but we'll ! * actually get the dbname by ProcessStartupPacket in the exec'd ! * process ! */ ! av[ac++] = "-p"; ! av[ac++] = "FORK_EXEC"; #else av[ac++] = "-p"; av[ac++] = port->database_name; --- 2593,2607 ---- * database to use. -p marks the end of secure switches. */ #ifdef EXEC_BACKEND /* pass data dir before end of secure switches (-p) */ av[ac++] = "-D"; av[ac++] = DataDir; ! /* and the backend identifier */ ! snprintf(idbuf, sizeof(idbuf), "-p%u", tmpBackendFileNum); ! av[ac++] = idbuf; ! #else av[ac++] = "-p"; av[ac++] = port->database_name; *************** *** 2612,2617 **** --- 2622,2628 ---- Assert(ac < maxac); + #ifndef EXEC_BACKEND /* * Release postmaster's working memory context so that backend can * recycle the space. Note this does not trash *MyProcPort, because *************** *** 2622,2634 **** MemoryContextSwitchTo(TopMemoryContext); MemoryContextDelete(PostmasterContext); PostmasterContext = NULL; /* * Debug: print arguments being passed to backend */ ereport(DEBUG3, (errmsg_internal("%s child[%d]: starting with (", ! progname, getpid()))); for (i = 0; i < ac; ++i) ereport(DEBUG3, (errmsg_internal("\t%s", av[i]))); --- 2633,2646 ---- MemoryContextSwitchTo(TopMemoryContext); MemoryContextDelete(PostmasterContext); PostmasterContext = NULL; + #endif /* * Debug: print arguments being passed to backend */ ereport(DEBUG3, (errmsg_internal("%s child[%d]: starting with (", ! progname, ExecBackend ? -1 : getpid()))); for (i = 0; i < ac; ++i) ereport(DEBUG3, (errmsg_internal("\t%s", av[i]))); *************** *** 2636,2642 **** (errmsg_internal(")"))); #ifdef EXEC_BACKEND ! return execv(pg_pathname,av); #else ClientAuthInProgress = false; /* client_min_messages is active * now */ --- 2648,2664 ---- (errmsg_internal(")"))); #ifdef EXEC_BACKEND ! /* EXEC_BACKEND case; fork/exec here */ ! if ((pid = fork()) == 0 && (execv(pg_pathname,av) == -1)) ! { ! /* in child */ ! elog(ERROR,"unable to execv in BackendFork: %m"); ! exit(0); ! } ! ! /* in parent */ ! pfree(av); ! return pid; #else ClientAuthInProgress = false; /* client_min_messages is active * now */ *************** *** 2851,2856 **** --- 2873,2881 ---- * * Return value of SSDataBase is subprocess' PID, or 0 if failed to start subprocess * (0 is returned only for checkpoint case). + * + * note: in the EXEC_BACKEND case, we delay the fork until argument list has been + * established */ NON_EXEC_STATIC void SSDataBaseInit(int xlop) *************** *** 2894,2909 **** { pid_t pid; Backend *bn; ! #ifdef LINUX_PROFILE struct itimerval prof_itimer; #endif fflush(stdout); fflush(stderr); #ifdef LINUX_PROFILE ! /* see comments in BackendStartup */ getitimer(ITIMER_PROF, &prof_itimer); #endif --- 2919,2938 ---- { pid_t pid; Backend *bn; ! #ifndef EXEC_BACKEND #ifdef LINUX_PROFILE struct itimerval prof_itimer; #endif + #else + char idbuf[32]; + #endif fflush(stdout); fflush(stderr); + #ifndef EXEC_BACKEND #ifdef LINUX_PROFILE ! /* see comments in BackendFork */ getitimer(ITIMER_PROF, &prof_itimer); #endif *************** *** 2912,2924 **** --- 2941,2956 ---- beos_before_backend_startup(); #endif + /* Non EXEC_BACKEND case; fork here */ if ((pid = fork()) == 0) /* child */ + #endif { char *av[10]; int ac = 0; char nbbuf[32]; char xlbuf[32]; + #ifndef EXEC_BACKEND #ifdef LINUX_PROFILE setitimer(ITIMER_PROF, &prof_itimer, NULL); #endif *************** *** 2931,2938 **** /* Close the postmaster's sockets */ ClosePostmasterPorts(true); - #ifndef EXEC_BACKEND SSDataBaseInit(xlop); #endif /* Set up command-line arguments for subprocess */ --- 2963,2972 ---- /* Close the postmaster's sockets */ ClosePostmasterPorts(true); SSDataBaseInit(xlop); + #else + if (!write_backend_variables(NULL)) + return -1; /* log issued by write_backend_variables */ #endif /* Set up command-line arguments for subprocess */ *************** *** 2941,2947 **** #ifdef EXEC_BACKEND av[ac++] = "-boot"; #endif - snprintf(nbbuf, sizeof(nbbuf), "-B%d", NBuffers); av[ac++] = nbbuf; --- 2975,2980 ---- *************** *** 2949,2970 **** av[ac++] = xlbuf; #ifdef EXEC_BACKEND - write_backend_variables(getpid(),NULL); - /* pass data dir before end of secure switches (-p) */ av[ac++] = "-D"; av[ac++] = DataDir; ! #endif av[ac++] = "-p"; av[ac++] = "template1"; av[ac] = (char *) NULL; Assert(ac < lengthof(av)); #ifdef EXEC_BACKEND ! if (execv(pg_pathname,av) == -1) ! elog(FATAL,"unable to execv in SSDataBase: %m"); #else BootstrapMain(ac, av); ExitPostmaster(0); --- 2982,3011 ---- av[ac++] = xlbuf; #ifdef EXEC_BACKEND /* pass data dir before end of secure switches (-p) */ av[ac++] = "-D"; av[ac++] = DataDir; ! ! /* and the backend identifier + dbname */ ! snprintf(idbuf, sizeof(idbuf), "-p%u,template1", tmpBackendFileNum); ! av[ac++] = idbuf; ! #else av[ac++] = "-p"; av[ac++] = "template1"; + #endif av[ac] = (char *) NULL; Assert(ac < lengthof(av)); #ifdef EXEC_BACKEND ! /* EXEC_BACKEND case; fork/exec here */ ! if ((pid = fork()) == 0 && (execv(pg_pathname,av) == -1)) ! { ! /* in child */ ! elog(ERROR,"unable to execv in SSDataBase: %m"); ! exit(0); ! } #else BootstrapMain(ac, av); ExitPostmaster(0); *************** *** 2974,2984 **** /* in parent */ if (pid < 0) { #ifdef __BEOS__ /* Specific beos actions before backend startup */ beos_backend_startup_failed(); #endif ! switch (xlop) { case BS_XLOG_STARTUP: --- 3015,3026 ---- /* in parent */ if (pid < 0) { + #ifndef EXEC_BACKEND #ifdef __BEOS__ /* Specific beos actions before backend startup */ beos_backend_startup_failed(); #endif ! #endif switch (xlop) { case BS_XLOG_STARTUP: *************** *** 3111,3116 **** --- 3153,3159 ---- * The following need to be available to the read/write_backend_variables * functions */ + #include "storage/spin.h" extern XLogRecPtr RedoRecPtr; extern XLogwrtResult LogwrtResult; extern slock_t *ShmemLock; *************** *** 3124,3145 **** #define write_var(var,fp) fwrite((void*)&(var),sizeof(var),1,fp) #define read_var(var,fp) fread((void*)&(var),sizeof(var),1,fp) #define get_tmp_backend_file_name(buf,id) \ ! do { \ ! Assert(DataDir); \ ! sprintf((buf), \ ! "%s/%s/%s.backend_var.%d", \ ! DataDir, \ ! PG_TEMP_FILES_DIR, \ ! PG_TEMP_FILE_PREFIX, \ ! (id)); \ ! } while (0) ! static void ! write_backend_variables(pid_t pid, Port *port) { char filename[MAXPGPATH]; FILE *fp; ! get_tmp_backend_file_name(filename,pid); /* Open file */ fp = AllocateFile(filename, PG_BINARY_W); --- 3167,3188 ---- #define write_var(var,fp) fwrite((void*)&(var),sizeof(var),1,fp) #define read_var(var,fp) fread((void*)&(var),sizeof(var),1,fp) #define get_tmp_backend_file_name(buf,id) \ ! do { \ ! Assert(DataDir); \ ! sprintf((buf), \ ! "%s/%s/%s.backend_var.%u", \ ! DataDir, \ ! PG_TEMP_FILES_DIR, \ ! PG_TEMP_FILE_PREFIX, \ ! (id)); \ ! } while (0) ! static bool ! write_backend_variables(Port *port) { char filename[MAXPGPATH]; FILE *fp; ! get_tmp_backend_file_name(filename,++tmpBackendFileNum); /* Open file */ fp = AllocateFile(filename, PG_BINARY_W); *************** *** 3156,3162 **** ereport(ERROR, (errcode_for_file_access(), errmsg("could not write to file \"%s\": %m", filename))); ! return; } } --- 3199,3205 ---- ereport(ERROR, (errcode_for_file_access(), errmsg("could not write to file \"%s\": %m", filename))); ! return false; } } *************** *** 3190,3203 **** /* Release file */ FreeFile(fp); } void ! read_backend_variables(pid_t pid, Port *port) { char filename[MAXPGPATH]; FILE *fp; ! get_tmp_backend_file_name(filename,pid); /* Open file */ fp = AllocateFile(filename, PG_BINARY_R); --- 3233,3247 ---- /* Release file */ FreeFile(fp); + return true; } void ! read_backend_variables(unsigned long id, Port *port) { char filename[MAXPGPATH]; FILE *fp; ! get_tmp_backend_file_name(filename,id); /* Open file */ fp = AllocateFile(filename, PG_BINARY_R); Index: src/backend/tcop/postgres.c =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/backend/tcop/postgres.c,v retrieving revision 1.381 diff -c -r1.381 postgres.c *** src/backend/tcop/postgres.c 25 Dec 2003 03:52:51 -0000 1.381 --- src/backend/tcop/postgres.c 26 Dec 2003 06:44:53 -0000 *************** *** 69,76 **** extern char *optarg; #ifdef EXEC_BACKEND ! extern bool BackendInit(Port*); ! extern void read_backend_variables(pid_t, Port*); #endif /* ---------------- --- 69,76 ---- extern char *optarg; #ifdef EXEC_BACKEND ! extern int BackendInit(Port*); ! extern void read_backend_variables(unsigned long, Port*); #endif /* ---------------- *************** *** 2033,2038 **** --- 2033,2041 ---- int firstchar; StringInfoData input_message; volatile bool send_rfq = true; + #ifdef EXEC_BACKEND + unsigned long backendID = 0; + #endif /* * Catch standard options before doing much else. This even works on *************** *** 2279,2284 **** --- 2282,2288 ---- { #ifdef EXEC_BACKEND IsUnderPostmaster = true; + backendID = (unsigned long)atol(optarg); #else dbname = strdup(optarg); #endif *************** *** 2494,2500 **** errmsg("insufficient memory to allocate port"))); read_nondefault_variables(); ! read_backend_variables(getpid(),port); /* FIXME: [fork/exec] Ugh */ load_hba(); --- 2498,2504 ---- errmsg("insufficient memory to allocate port"))); read_nondefault_variables(); ! read_backend_variables(backendID,port); /* FIXME: [fork/exec] Ugh */ load_hba();