PostgreSQL Source Code  git master
postmaster.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define POSTMASTER_FD_WATCH
 
#define POSTMASTER_FD_OWN   1 /* kept open by postmaster only */
 
#define MAX_BACKENDS   0x3FFFF
 

Functions

void PostmasterMain (int argc, char *argv[]) pg_attribute_noreturn()
 
void ClosePostmasterPorts (bool am_syslogger)
 
void InitProcessGlobals (void)
 
int MaxLivePostmasterChildren (void)
 
bool PostmasterMarkPIDForWorkerNotify (int)
 

Variables

bool EnableSSL
 
int ReservedBackends
 
PGDLLIMPORT int PostPortNumber
 
int Unix_socket_permissions
 
char * Unix_socket_group
 
char * Unix_socket_directories
 
char * ListenAddresses
 
bool ClientAuthInProgress
 
int PreAuthDelay
 
int AuthenticationTimeout
 
bool Log_connections
 
bool log_hostname
 
bool enable_bonjour
 
char * bonjour_name
 
bool restart_after_crash
 
bool remove_temp_files_after_crash
 
int postmaster_alive_fds [2]
 
PGDLLIMPORT const char * progname
 

Macro Definition Documentation

◆ MAX_BACKENDS

#define MAX_BACKENDS   0x3FFFF

Definition at line 75 of file postmaster.h.

◆ POSTMASTER_FD_OWN

#define POSTMASTER_FD_OWN   1 /* kept open by postmaster only */

Definition at line 44 of file postmaster.h.

◆ POSTMASTER_FD_WATCH

#define POSTMASTER_FD_WATCH
Value:
0 /* used in children to check for
* postmaster death */

Definition at line 43 of file postmaster.h.

Function Documentation

◆ ClosePostmasterPorts()

void ClosePostmasterPorts ( bool  am_syslogger)

Definition at line 2637 of file postmaster.c.

2638 {
2639  int i;
2640 
2641 #ifndef WIN32
2642 
2643  /*
2644  * Close the write end of postmaster death watch pipe. It's important to
2645  * do this as early as possible, so that if postmaster dies, others won't
2646  * think that it's still running because we're holding the pipe open.
2647  */
2649  ereport(FATAL,
2651  errmsg_internal("could not close postmaster death monitoring pipe in child process: %m")));
2653  /* Notify fd.c that we released one pipe FD. */
2655 #endif
2656 
2657  /*
2658  * Close the postmaster's listen sockets. These aren't tracked by fd.c,
2659  * so we don't call ReleaseExternalFD() here.
2660  */
2661  for (i = 0; i < MAXLISTEN; i++)
2662  {
2664  {
2667  }
2668  }
2669 
2670  /*
2671  * If using syslogger, close the read side of the pipe. We don't bother
2672  * tracking this in fd.c, either.
2673  */
2674  if (!am_syslogger)
2675  {
2676 #ifndef WIN32
2677  if (syslogPipe[0] >= 0)
2678  close(syslogPipe[0]);
2679  syslogPipe[0] = -1;
2680 #else
2681  if (syslogPipe[0])
2682  CloseHandle(syslogPipe[0]);
2683  syslogPipe[0] = 0;
2684 #endif
2685  }
2686 
2687 #ifdef USE_BONJOUR
2688  /* If using Bonjour, close the connection to the mDNS daemon */
2689  if (bonjour_sdref)
2690  close(DNSServiceRefSockFD(bonjour_sdref));
2691 #endif
2692 }
int errmsg_internal(const char *fmt,...)
Definition: elog.c:991
int errcode_for_file_access(void)
Definition: elog.c:716
#define FATAL
Definition: elog.h:35
#define ereport(elevel,...)
Definition: elog.h:143
void ReleaseExternalFD(void)
Definition: fd.c:1230
#define close(a)
Definition: win32.h:12
int i
Definition: isn.c:73
#define PGINVALID_SOCKET
Definition: port.h:31
int postmaster_alive_fds[2]
Definition: postmaster.c:572
#define MAXLISTEN
Definition: postmaster.c:221
static pgsocket ListenSocket[MAXLISTEN]
Definition: postmaster.c:222
#define POSTMASTER_FD_OWN
Definition: postmaster.h:44
void StreamClose(pgsocket sock)
Definition: pqcomm.c:865
int syslogPipe[2]
Definition: syslogger.c:117

References close, ereport, errcode_for_file_access(), errmsg_internal(), FATAL, i, ListenSocket, MAXLISTEN, PGINVALID_SOCKET, postmaster_alive_fds, POSTMASTER_FD_OWN, ReleaseExternalFD(), StreamClose(), and syslogPipe.

Referenced by BackendStartup(), do_start_bgworker(), pgstat_start(), StartAutoVacWorker(), StartChildProcess(), and SysLogger_Start().

◆ InitProcessGlobals()

void InitProcessGlobals ( void  )

Definition at line 2701 of file postmaster.c.

2702 {
2703  MyProcPid = getpid();
2706 
2707  /*
2708  * Set a different global seed in every process. We want something
2709  * unpredictable, so if possible, use high-quality random bits for the
2710  * seed. Otherwise, fall back to a seed based on timestamp and PID.
2711  */
2713  {
2714  uint64 rseed;
2715 
2716  /*
2717  * Since PIDs and timestamps tend to change more frequently in their
2718  * least significant bits, shift the timestamp left to allow a larger
2719  * total number of seeds in a given time period. Since that would
2720  * leave only 20 bits of the timestamp that cycle every ~1 second,
2721  * also mix in some higher bits.
2722  */
2723  rseed = ((uint64) MyProcPid) ^
2724  ((uint64) MyStartTimestamp << 12) ^
2725  ((uint64) MyStartTimestamp >> 20);
2726 
2728  }
2729 
2730  /*
2731  * Also make sure that we've set a good seed for random(3). Use of that
2732  * is deprecated in core Postgres, but extensions might use it.
2733  */
2734 #ifndef WIN32
2736 #endif
2737 }
TimestampTz GetCurrentTimestamp(void)
Definition: timestamp.c:1580
pg_time_t timestamptz_to_time_t(TimestampTz t)
Definition: timestamp.c:1754
#define unlikely(x)
Definition: c.h:273
int MyProcPid
Definition: globals.c:43
TimestampTz MyStartTimestamp
Definition: globals.c:45
pg_time_t MyStartTime
Definition: globals.c:44
uint32 pg_prng_uint32(pg_prng_state *state)
Definition: pg_prng.c:185
void pg_prng_seed(pg_prng_state *state, uint64 seed)
Definition: pg_prng.c:83
pg_prng_state pg_global_prng_state
Definition: pg_prng.c:28
#define pg_prng_strong_seed(state)
Definition: pg_prng.h:46

References GetCurrentTimestamp(), MyProcPid, MyStartTime, MyStartTimestamp, pg_global_prng_state, pg_prng_seed(), pg_prng_strong_seed, pg_prng_uint32(), timestamptz_to_time_t(), and unlikely.

Referenced by InitPostmasterChild(), InitStandaloneProcess(), and PostmasterMain().

◆ MaxLivePostmasterChildren()

int MaxLivePostmasterChildren ( void  )

Definition at line 5753 of file postmaster.c.

5754 {
5755  return 2 * (MaxConnections + autovacuum_max_workers + 1 +
5757 }
int autovacuum_max_workers
Definition: autovacuum.c:115
int MaxConnections
Definition: globals.c:136
int max_worker_processes
Definition: globals.c:137
int max_wal_senders
Definition: walsender.c:121

References autovacuum_max_workers, max_wal_senders, max_worker_processes, and MaxConnections.

Referenced by canAcceptConnections(), PMSignalShmemInit(), PMSignalShmemSize(), and processCancelRequest().

◆ PostmasterMain()

void PostmasterMain ( int  argc,
char *  argv[] 
)

Definition at line 582 of file postmaster.c.

583 {
584  int opt;
585  int status;
586  char *userDoption = NULL;
587  bool listen_addr_saved = false;
588  int i;
589  char *output_config_variable = NULL;
590 
592 
594 
596 
597  /*
598  * Start our win32 signal implementation
599  */
600 #ifdef WIN32
602 #endif
603 
604  /*
605  * We should not be creating any files or directories before we check the
606  * data directory (see checkDataDir()), but just in case set the umask to
607  * the most restrictive (owner-only) permissions.
608  *
609  * checkDataDir() will reset the umask based on the data directory
610  * permissions.
611  */
612  umask(PG_MODE_MASK_OWNER);
613 
614  /*
615  * By default, palloc() requests in the postmaster will be allocated in
616  * the PostmasterContext, which is space that can be recycled by backends.
617  * Allocated data that needs to be available to backends should be
618  * allocated in TopMemoryContext.
619  */
621  "Postmaster",
624 
625  /* Initialize paths to installation files */
626  getInstallationPaths(argv[0]);
627 
628  /*
629  * Set up signal handlers for the postmaster process.
630  *
631  * In the postmaster, we use pqsignal_pm() rather than pqsignal() (which
632  * is used by all child processes and client processes). That has a
633  * couple of special behaviors:
634  *
635  * 1. Except on Windows, we tell sigaction() to block all signals for the
636  * duration of the signal handler. This is faster than our old approach
637  * of blocking/unblocking explicitly in the signal handler, and it should
638  * also prevent excessive stack consumption if signals arrive quickly.
639  *
640  * 2. We do not set the SA_RESTART flag. This is because signals will be
641  * blocked at all times except when ServerLoop is waiting for something to
642  * happen, and during that window, we want signals to exit the select(2)
643  * wait so that ServerLoop can respond if anything interesting happened.
644  * On some platforms, signals marked SA_RESTART would not cause the
645  * select() wait to end.
646  *
647  * Child processes will generally want SA_RESTART, so pqsignal() sets that
648  * flag. We expect children to set up their own handlers before
649  * unblocking signals.
650  *
651  * CAUTION: when changing this list, check for side-effects on the signal
652  * handling setup of child processes. See tcop/postgres.c,
653  * bootstrap/bootstrap.c, postmaster/bgwriter.c, postmaster/walwriter.c,
654  * postmaster/autovacuum.c, postmaster/pgarch.c, postmaster/pgstat.c,
655  * postmaster/syslogger.c, postmaster/bgworker.c and
656  * postmaster/checkpointer.c.
657  */
658  pqinitmask();
660 
661  pqsignal_pm(SIGHUP, SIGHUP_handler); /* reread config file and have
662  * children do same */
663  pqsignal_pm(SIGINT, pmdie); /* send SIGTERM and shut down */
664  pqsignal_pm(SIGQUIT, pmdie); /* send SIGQUIT and die */
665  pqsignal_pm(SIGTERM, pmdie); /* wait for children and shut down */
666  pqsignal_pm(SIGALRM, SIG_IGN); /* ignored */
667  pqsignal_pm(SIGPIPE, SIG_IGN); /* ignored */
668  pqsignal_pm(SIGUSR1, sigusr1_handler); /* message from child process */
669  pqsignal_pm(SIGUSR2, dummy_handler); /* unused, reserve for children */
670  pqsignal_pm(SIGCHLD, reaper); /* handle child termination */
671 
672 #ifdef SIGURG
673 
674  /*
675  * Ignore SIGURG for now. Child processes may change this (see
676  * InitializeLatchSupport), but they will not receive any such signals
677  * until they wait on a latch.
678  */
679  pqsignal_pm(SIGURG, SIG_IGN); /* ignored */
680 #endif
681 
682  /*
683  * No other place in Postgres should touch SIGTTIN/SIGTTOU handling. We
684  * ignore those signals in a postmaster environment, so that there is no
685  * risk of a child process freezing up due to writing to stderr. But for
686  * a standalone backend, their default handling is reasonable. Hence, all
687  * child processes should just allow the inherited settings to stand.
688  */
689 #ifdef SIGTTIN
690  pqsignal_pm(SIGTTIN, SIG_IGN); /* ignored */
691 #endif
692 #ifdef SIGTTOU
693  pqsignal_pm(SIGTTOU, SIG_IGN); /* ignored */
694 #endif
695 
696  /* ignore SIGXFSZ, so that ulimit violations work like disk full */
697 #ifdef SIGXFSZ
698  pqsignal_pm(SIGXFSZ, SIG_IGN); /* ignored */
699 #endif
700 
701  /*
702  * Options setup
703  */
705 
706  opterr = 1;
707 
708  /*
709  * Parse command-line options. CAUTION: keep this in sync with
710  * tcop/postgres.c (the option sets should not conflict) and with the
711  * common help() function in main/main.c.
712  */
713  while ((opt = getopt(argc, argv, "B:bc:C:D:d:EeFf:h:ijk:lN:nOPp:r:S:sTt:W:-:")) != -1)
714  {
715  switch (opt)
716  {
717  case 'B':
718  SetConfigOption("shared_buffers", optarg, PGC_POSTMASTER, PGC_S_ARGV);
719  break;
720 
721  case 'b':
722  /* Undocumented flag used for binary upgrades */
723  IsBinaryUpgrade = true;
724  break;
725 
726  case 'C':
727  output_config_variable = strdup(optarg);
728  break;
729 
730  case 'D':
731  userDoption = strdup(optarg);
732  break;
733 
734  case 'd':
736  break;
737 
738  case 'E':
739  SetConfigOption("log_statement", "all", PGC_POSTMASTER, PGC_S_ARGV);
740  break;
741 
742  case 'e':
743  SetConfigOption("datestyle", "euro", PGC_POSTMASTER, PGC_S_ARGV);
744  break;
745 
746  case 'F':
747  SetConfigOption("fsync", "false", PGC_POSTMASTER, PGC_S_ARGV);
748  break;
749 
750  case 'f':
752  {
753  write_stderr("%s: invalid argument for option -f: \"%s\"\n",
754  progname, optarg);
755  ExitPostmaster(1);
756  }
757  break;
758 
759  case 'h':
760  SetConfigOption("listen_addresses", optarg, PGC_POSTMASTER, PGC_S_ARGV);
761  break;
762 
763  case 'i':
764  SetConfigOption("listen_addresses", "*", PGC_POSTMASTER, PGC_S_ARGV);
765  break;
766 
767  case 'j':
768  /* only used by interactive backend */
769  break;
770 
771  case 'k':
772  SetConfigOption("unix_socket_directories", optarg, PGC_POSTMASTER, PGC_S_ARGV);
773  break;
774 
775  case 'l':
776  SetConfigOption("ssl", "true", PGC_POSTMASTER, PGC_S_ARGV);
777  break;
778 
779  case 'N':
780  SetConfigOption("max_connections", optarg, PGC_POSTMASTER, PGC_S_ARGV);
781  break;
782 
783  case 'n':
784  /* Don't reinit shared mem after abnormal exit */
785  Reinit = false;
786  break;
787 
788  case 'O':
789  SetConfigOption("allow_system_table_mods", "true", PGC_POSTMASTER, PGC_S_ARGV);
790  break;
791 
792  case 'P':
793  SetConfigOption("ignore_system_indexes", "true", PGC_POSTMASTER, PGC_S_ARGV);
794  break;
795 
796  case 'p':
798  break;
799 
800  case 'r':
801  /* only used by single-user backend */
802  break;
803 
804  case 'S':
806  break;
807 
808  case 's':
809  SetConfigOption("log_statement_stats", "true", PGC_POSTMASTER, PGC_S_ARGV);
810  break;
811 
812  case 'T':
813 
814  /*
815  * In the event that some backend dumps core, send SIGSTOP,
816  * rather than SIGQUIT, to all its peers. This lets the wily
817  * post_hacker collect core dumps from everyone.
818  */
819  SendStop = true;
820  break;
821 
822  case 't':
823  {
824  const char *tmp = get_stats_option_name(optarg);
825 
826  if (tmp)
827  {
829  }
830  else
831  {
832  write_stderr("%s: invalid argument for option -t: \"%s\"\n",
833  progname, optarg);
834  ExitPostmaster(1);
835  }
836  break;
837  }
838 
839  case 'W':
840  SetConfigOption("post_auth_delay", optarg, PGC_POSTMASTER, PGC_S_ARGV);
841  break;
842 
843  case 'c':
844  case '-':
845  {
846  char *name,
847  *value;
848 
850  if (!value)
851  {
852  if (opt == '-')
853  ereport(ERROR,
854  (errcode(ERRCODE_SYNTAX_ERROR),
855  errmsg("--%s requires a value",
856  optarg)));
857  else
858  ereport(ERROR,
859  (errcode(ERRCODE_SYNTAX_ERROR),
860  errmsg("-c %s requires a value",
861  optarg)));
862  }
863 
865  free(name);
866  if (value)
867  free(value);
868  break;
869  }
870 
871  default:
872  write_stderr("Try \"%s --help\" for more information.\n",
873  progname);
874  ExitPostmaster(1);
875  }
876  }
877 
878  /*
879  * Postmaster accepts no non-option switch arguments.
880  */
881  if (optind < argc)
882  {
883  write_stderr("%s: invalid argument: \"%s\"\n",
884  progname, argv[optind]);
885  write_stderr("Try \"%s --help\" for more information.\n",
886  progname);
887  ExitPostmaster(1);
888  }
889 
890  /*
891  * Locate the proper configuration files and data directory, and read
892  * postgresql.conf for the first time.
893  */
895  ExitPostmaster(2);
896 
897  if (output_config_variable != NULL)
898  {
899  /*
900  * If this is a runtime-computed GUC, it hasn't yet been initialized,
901  * and the present value is not useful. However, this is a convenient
902  * place to print the value for most GUCs because it is safe to run
903  * postmaster startup to this point even if the server is already
904  * running. For the handful of runtime-computed GUCs that we cannot
905  * provide meaningful values for yet, we wait until later in
906  * postmaster startup to print the value. We won't be able to use -C
907  * on running servers for those GUCs, but using this option now would
908  * lead to incorrect results for them.
909  */
910  int flags = GetConfigOptionFlags(output_config_variable, true);
911 
912  if ((flags & GUC_RUNTIME_COMPUTED) == 0)
913  {
914  /*
915  * "-C guc" was specified, so print GUC's value and exit. No
916  * extra permission check is needed because the user is reading
917  * inside the data dir.
918  */
919  const char *config_val = GetConfigOption(output_config_variable,
920  false, false);
921 
922  puts(config_val ? config_val : "");
923  ExitPostmaster(0);
924  }
925  }
926 
927  /* Verify that DataDir looks reasonable */
928  checkDataDir();
929 
930  /* Check that pg_control exists */
932 
933  /* And switch working directory into it */
934  ChangeToDataDir();
935 
936  /*
937  * Check for invalid combinations of GUC settings.
938  */
940  {
941  write_stderr("%s: superuser_reserved_connections (%d) must be less than max_connections (%d)\n",
942  progname,
944  ExitPostmaster(1);
945  }
947  ereport(ERROR,
948  (errmsg("WAL archival cannot be enabled when wal_level is \"minimal\"")));
950  ereport(ERROR,
951  (errmsg("WAL streaming (max_wal_senders > 0) requires wal_level \"replica\" or \"logical\"")));
952 
953  /*
954  * Other one-time internal sanity checks can go here, if they are fast.
955  * (Put any slow processing further down, after postmaster.pid creation.)
956  */
957  if (!CheckDateTokenTables())
958  {
959  write_stderr("%s: invalid datetoken tables, please fix\n", progname);
960  ExitPostmaster(1);
961  }
962 
963  /*
964  * Now that we are done processing the postmaster arguments, reset
965  * getopt(3) library so that it will work correctly in subprocesses.
966  */
967  optind = 1;
968 #ifdef HAVE_INT_OPTRESET
969  optreset = 1; /* some systems need this too */
970 #endif
971 
972  /* For debugging: display postmaster environment */
973  {
974  extern char **environ;
975  char **p;
976 
977  ereport(DEBUG3,
978  (errmsg_internal("%s: PostmasterMain: initial environment dump:",
979  progname)));
980  ereport(DEBUG3,
981  (errmsg_internal("-----------------------------------------")));
982  for (p = environ; *p; ++p)
983  ereport(DEBUG3,
984  (errmsg_internal("\t%s", *p)));
985  ereport(DEBUG3,
986  (errmsg_internal("-----------------------------------------")));
987  }
988 
989  /*
990  * Create lockfile for data directory.
991  *
992  * We want to do this before we try to grab the input sockets, because the
993  * data directory interlock is more reliable than the socket-file
994  * interlock (thanks to whoever decided to put socket files in /tmp :-().
995  * For the same reason, it's best to grab the TCP socket(s) before the
996  * Unix socket(s).
997  *
998  * Also note that this internally sets up the on_proc_exit function that
999  * is responsible for removing both data directory and socket lockfiles;
1000  * so it must happen before opening sockets so that at exit, the socket
1001  * lockfiles go away after CloseServerPorts runs.
1002  */
1003  CreateDataDirLockFile(true);
1004 
1005  /*
1006  * Read the control file (for error checking and config info).
1007  *
1008  * Since we verify the control file's CRC, this has a useful side effect
1009  * on machines where we need a run-time test for CRC support instructions.
1010  * The postmaster will do the test once at startup, and then its child
1011  * processes will inherit the correct function pointer and not need to
1012  * repeat the test.
1013  */
1014  LocalProcessControlFile(false);
1015 
1016  /*
1017  * Register the apply launcher. Since it registers a background worker,
1018  * it needs to be called before InitializeMaxBackends(), and it's probably
1019  * a good idea to call it before any modules had chance to take the
1020  * background worker slots.
1021  */
1023 
1024  /*
1025  * process any libraries that should be preloaded at postmaster start
1026  */
1028 
1029  /*
1030  * Initialize SSL library, if specified.
1031  */
1032 #ifdef USE_SSL
1033  if (EnableSSL)
1034  {
1035  (void) secure_initialize(true);
1036  LoadedSSL = true;
1037  }
1038 #endif
1039 
1040  /*
1041  * Now that loadable modules have had their chance to register background
1042  * workers, calculate MaxBackends.
1043  */
1045 
1046  /*
1047  * Now that loadable modules have had their chance to request additional
1048  * shared memory, determine the value of any runtime-computed GUCs that
1049  * depend on the amount of shared memory required.
1050  */
1052 
1053  /*
1054  * If -C was specified with a runtime-computed GUC, we held off printing
1055  * the value earlier, as the GUC was not yet initialized. We handle -C
1056  * for most GUCs before we lock the data directory so that the option may
1057  * be used on a running server. However, a handful of GUCs are runtime-
1058  * computed and do not have meaningful values until after locking the data
1059  * directory, and we cannot safely calculate their values earlier on a
1060  * running server. At this point, such GUCs should be properly
1061  * initialized, and we haven't yet set up shared memory, so this is a good
1062  * time to handle the -C option for these special GUCs.
1063  */
1064  if (output_config_variable != NULL)
1065  {
1066  const char *config_val = GetConfigOption(output_config_variable,
1067  false, false);
1068 
1069  puts(config_val ? config_val : "");
1070  ExitPostmaster(0);
1071  }
1072 
1073  /*
1074  * Set up shared memory and semaphores.
1075  */
1076  reset_shared();
1077 
1078  /*
1079  * Estimate number of openable files. This must happen after setting up
1080  * semaphores, because on some platforms semaphores count as open files.
1081  */
1082  set_max_safe_fds();
1083 
1084  /*
1085  * Set reference point for stack-depth checking.
1086  */
1087  set_stack_base();
1088 
1089  /*
1090  * Initialize pipe (or process handle on Windows) that allows children to
1091  * wake up from sleep on postmaster death.
1092  */
1094 
1095 #ifdef WIN32
1096 
1097  /*
1098  * Initialize I/O completion port used to deliver list of dead children.
1099  */
1100  win32ChildQueue = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 1);
1101  if (win32ChildQueue == NULL)
1102  ereport(FATAL,
1103  (errmsg("could not create I/O completion port for child queue")));
1104 #endif
1105 
1106 #ifdef EXEC_BACKEND
1107  /* Write out nondefault GUC settings for child processes to use */
1108  write_nondefault_variables(PGC_POSTMASTER);
1109 
1110  /*
1111  * Clean out the temp directory used to transmit parameters to child
1112  * processes (see internal_forkexec, below). We must do this before
1113  * launching any child processes, else we have a race condition: we could
1114  * remove a parameter file before the child can read it. It should be
1115  * safe to do so now, because we verified earlier that there are no
1116  * conflicting Postgres processes in this data directory.
1117  */
1119 #endif
1120 
1121  /*
1122  * Forcibly remove the files signaling a standby promotion request.
1123  * Otherwise, the existence of those files triggers a promotion too early,
1124  * whether a user wants that or not.
1125  *
1126  * This removal of files is usually unnecessary because they can exist
1127  * only during a few moments during a standby promotion. However there is
1128  * a race condition: if pg_ctl promote is executed and creates the files
1129  * during a promotion, the files can stay around even after the server is
1130  * brought up to be the primary. Then, if a new standby starts by using
1131  * the backup taken from the new primary, the files can exist at server
1132  * startup and must be removed in order to avoid an unexpected promotion.
1133  *
1134  * Note that promotion signal files need to be removed before the startup
1135  * process is invoked. Because, after that, they can be used by
1136  * postmaster's SIGUSR1 signal handler.
1137  */
1139 
1140  /* Do the same for logrotate signal file */
1142 
1143  /* Remove any outdated file holding the current log filenames. */
1144  if (unlink(LOG_METAINFO_DATAFILE) < 0 && errno != ENOENT)
1145  ereport(LOG,
1147  errmsg("could not remove file \"%s\": %m",
1149 
1150  /*
1151  * If enabled, start up syslogger collection subprocess
1152  */
1154 
1155  /*
1156  * Reset whereToSendOutput from DestDebug (its starting state) to
1157  * DestNone. This stops ereport from sending log messages to stderr unless
1158  * Log_destination permits. We don't do this until the postmaster is
1159  * fully launched, since startup failures may as well be reported to
1160  * stderr.
1161  *
1162  * If we are in fact disabling logging to stderr, first emit a log message
1163  * saying so, to provide a breadcrumb trail for users who may not remember
1164  * that their logging is configured to go somewhere else.
1165  */
1167  ereport(LOG,
1168  (errmsg("ending log output to stderr"),
1169  errhint("Future log output will go to log destination \"%s\".",
1171 
1173 
1174  /*
1175  * Report server startup in log. While we could emit this much earlier,
1176  * it seems best to do so after starting the log collector, if we intend
1177  * to use one.
1178  */
1179  ereport(LOG,
1180  (errmsg("starting %s", PG_VERSION_STR)));
1181 
1182  /*
1183  * Establish input sockets.
1184  *
1185  * First, mark them all closed, and set up an on_proc_exit function that's
1186  * charged with closing the sockets again at postmaster shutdown.
1187  */
1188  for (i = 0; i < MAXLISTEN; i++)
1190 
1192 
1193  if (ListenAddresses)
1194  {
1195  char *rawstring;
1196  List *elemlist;
1197  ListCell *l;
1198  int success = 0;
1199 
1200  /* Need a modifiable copy of ListenAddresses */
1201  rawstring = pstrdup(ListenAddresses);
1202 
1203  /* Parse string into list of hostnames */
1204  if (!SplitGUCList(rawstring, ',', &elemlist))
1205  {
1206  /* syntax error in list */
1207  ereport(FATAL,
1208  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1209  errmsg("invalid list syntax in parameter \"%s\"",
1210  "listen_addresses")));
1211  }
1212 
1213  foreach(l, elemlist)
1214  {
1215  char *curhost = (char *) lfirst(l);
1216 
1217  if (strcmp(curhost, "*") == 0)
1218  status = StreamServerPort(AF_UNSPEC, NULL,
1219  (unsigned short) PostPortNumber,
1220  NULL,
1222  else
1223  status = StreamServerPort(AF_UNSPEC, curhost,
1224  (unsigned short) PostPortNumber,
1225  NULL,
1227 
1228  if (status == STATUS_OK)
1229  {
1230  success++;
1231  /* record the first successful host addr in lockfile */
1232  if (!listen_addr_saved)
1233  {
1235  listen_addr_saved = true;
1236  }
1237  }
1238  else
1239  ereport(WARNING,
1240  (errmsg("could not create listen socket for \"%s\"",
1241  curhost)));
1242  }
1243 
1244  if (!success && elemlist != NIL)
1245  ereport(FATAL,
1246  (errmsg("could not create any TCP/IP sockets")));
1247 
1248  list_free(elemlist);
1249  pfree(rawstring);
1250  }
1251 
1252 #ifdef USE_BONJOUR
1253  /* Register for Bonjour only if we opened TCP socket(s) */
1255  {
1256  DNSServiceErrorType err;
1257 
1258  /*
1259  * We pass 0 for interface_index, which will result in registering on
1260  * all "applicable" interfaces. It's not entirely clear from the
1261  * DNS-SD docs whether this would be appropriate if we have bound to
1262  * just a subset of the available network interfaces.
1263  */
1264  err = DNSServiceRegister(&bonjour_sdref,
1265  0,
1266  0,
1267  bonjour_name,
1268  "_postgresql._tcp.",
1269  NULL,
1270  NULL,
1272  0,
1273  NULL,
1274  NULL,
1275  NULL);
1276  if (err != kDNSServiceErr_NoError)
1277  ereport(LOG,
1278  (errmsg("DNSServiceRegister() failed: error code %ld",
1279  (long) err)));
1280 
1281  /*
1282  * We don't bother to read the mDNS daemon's reply, and we expect that
1283  * it will automatically terminate our registration when the socket is
1284  * closed at postmaster termination. So there's nothing more to be
1285  * done here. However, the bonjour_sdref is kept around so that
1286  * forked children can close their copies of the socket.
1287  */
1288  }
1289 #endif
1290 
1291 #ifdef HAVE_UNIX_SOCKETS
1293  {
1294  char *rawstring;
1295  List *elemlist;
1296  ListCell *l;
1297  int success = 0;
1298 
1299  /* Need a modifiable copy of Unix_socket_directories */
1300  rawstring = pstrdup(Unix_socket_directories);
1301 
1302  /* Parse string into list of directories */
1303  if (!SplitDirectoriesString(rawstring, ',', &elemlist))
1304  {
1305  /* syntax error in list */
1306  ereport(FATAL,
1307  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1308  errmsg("invalid list syntax in parameter \"%s\"",
1309  "unix_socket_directories")));
1310  }
1311 
1312  foreach(l, elemlist)
1313  {
1314  char *socketdir = (char *) lfirst(l);
1315 
1316  status = StreamServerPort(AF_UNIX, NULL,
1317  (unsigned short) PostPortNumber,
1318  socketdir,
1320 
1321  if (status == STATUS_OK)
1322  {
1323  success++;
1324  /* record the first successful Unix socket in lockfile */
1325  if (success == 1)
1327  }
1328  else
1329  ereport(WARNING,
1330  (errmsg("could not create Unix-domain socket in directory \"%s\"",
1331  socketdir)));
1332  }
1333 
1334  if (!success && elemlist != NIL)
1335  ereport(FATAL,
1336  (errmsg("could not create any Unix-domain sockets")));
1337 
1338  list_free_deep(elemlist);
1339  pfree(rawstring);
1340  }
1341 #endif
1342 
1343  /*
1344  * check that we have some socket to listen on
1345  */
1346  if (ListenSocket[0] == PGINVALID_SOCKET)
1347  ereport(FATAL,
1348  (errmsg("no socket created for listening")));
1349 
1350  /*
1351  * If no valid TCP ports, write an empty line for listen address,
1352  * indicating the Unix socket must be used. Note that this line is not
1353  * added to the lock file until there is a socket backing it.
1354  */
1355  if (!listen_addr_saved)
1357 
1358  /*
1359  * Record postmaster options. We delay this till now to avoid recording
1360  * bogus options (eg, unusable port number).
1361  */
1362  if (!CreateOptsFile(argc, argv, my_exec_path))
1363  ExitPostmaster(1);
1364 
1365  /*
1366  * Write the external PID file if requested
1367  */
1368  if (external_pid_file)
1369  {
1370  FILE *fpidfile = fopen(external_pid_file, "w");
1371 
1372  if (fpidfile)
1373  {
1374  fprintf(fpidfile, "%d\n", MyProcPid);
1375  fclose(fpidfile);
1376 
1377  /* Make PID file world readable */
1378  if (chmod(external_pid_file, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) != 0)
1379  write_stderr("%s: could not change permissions of external PID file \"%s\": %s\n",
1381  }
1382  else
1383  write_stderr("%s: could not write external PID file \"%s\": %s\n",
1385 
1387  }
1388 
1389  /*
1390  * Remove old temporary files. At this point there can be no other
1391  * Postgres processes running in this directory, so this should be safe.
1392  */
1394 
1395  /*
1396  * Initialize stats collection subsystem (this does NOT start the
1397  * collector process!)
1398  */
1399  pgstat_init();
1400 
1401  /*
1402  * Initialize the autovacuum subsystem (again, no process start yet)
1403  */
1404  autovac_init();
1405 
1406  /*
1407  * Load configuration files for client authentication.
1408  */
1409  if (!load_hba())
1410  {
1411  /*
1412  * It makes no sense to continue if we fail to load the HBA file,
1413  * since there is no way to connect to the database in this case.
1414  */
1415  ereport(FATAL,
1416  (errmsg("could not load pg_hba.conf")));
1417  }
1418  if (!load_ident())
1419  {
1420  /*
1421  * We can start up without the IDENT file, although it means that you
1422  * cannot log in using any of the authentication methods that need a
1423  * user name mapping. load_ident() already logged the details of error
1424  * to the log.
1425  */
1426  }
1427 
1428 #ifdef HAVE_PTHREAD_IS_THREADED_NP
1429 
1430  /*
1431  * On macOS, libintl replaces setlocale() with a version that calls
1432  * CFLocaleCopyCurrent() when its second argument is "" and every relevant
1433  * environment variable is unset or empty. CFLocaleCopyCurrent() makes
1434  * the process multithreaded. The postmaster calls sigprocmask() and
1435  * calls fork() without an immediate exec(), both of which have undefined
1436  * behavior in a multithreaded program. A multithreaded postmaster is the
1437  * normal case on Windows, which offers neither fork() nor sigprocmask().
1438  */
1439  if (pthread_is_threaded_np() != 0)
1440  ereport(FATAL,
1441  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
1442  errmsg("postmaster became multithreaded during startup"),
1443  errhint("Set the LC_ALL environment variable to a valid locale.")));
1444 #endif
1445 
1446  /*
1447  * Remember postmaster startup time
1448  */
1450 
1451  /*
1452  * Report postmaster status in the postmaster.pid file, to allow pg_ctl to
1453  * see what's happening.
1454  */
1456 
1457  /* Start bgwriter and checkpointer so they can help with recovery */
1458  if (CheckpointerPID == 0)
1460  if (BgWriterPID == 0)
1462 
1463  /*
1464  * We're ready to rock and roll...
1465  */
1467  Assert(StartupPID != 0);
1469  pmState = PM_STARTUP;
1470 
1471  /* Some workers may be scheduled to start now */
1473 
1474  status = ServerLoop();
1475 
1476  /*
1477  * ServerLoop probably shouldn't ever return, but if it does, close down.
1478  */
1480 
1481  abort(); /* not reached */
1482 }
void autovac_init(void)
Definition: autovacuum.c:3391
void pqinitmask(void)
Definition: pqsignal.c:41
pqsigfunc pqsignal_pm(int signo, pqsigfunc func)
Definition: pqsignal.c:120
sigset_t BlockSig
Definition: pqsignal.c:23
bool CheckDateTokenTables(void)
Definition: datetime.c:4465
TimestampTz PgStartTime
Definition: timestamp.c:52
int secure_initialize(bool isServerStart)
Definition: be-secure.c:78
#define write_stderr(str)
Definition: parallel.c:186
#define STATUS_OK
Definition: c.h:1167
@ DestNone
Definition: dest.h:89
int Log_destination
Definition: elog.c:111
int errhint(const char *fmt,...)
Definition: elog.c:1151
char * Log_destination_string
Definition: elog.c:112
int errcode(int sqlerrcode)
Definition: elog.c:693
int errmsg(const char *fmt,...)
Definition: elog.c:904
#define LOG
Definition: elog.h:25
#define DEBUG3
Definition: elog.h:22
#define WARNING
Definition: elog.h:30
#define ERROR
Definition: elog.h:33
#define LOG_DESTINATION_STDERR
Definition: elog.h:421
const char * name
Definition: encode.c:561
void RemovePgTempFilesInDir(const char *tmpdirname, bool missing_ok, bool unlink_all)
Definition: fd.c:3212
void RemovePgTempFiles(void)
Definition: fd.c:3153
void set_max_safe_fds(void)
Definition: fd.c:1028
#define PG_MODE_MASK_OWNER
Definition: file_perm.h:24
bool IsBinaryUpgrade
Definition: globals.c:113
pid_t PostmasterPid
Definition: globals.c:98
bool IsPostmasterEnvironment
Definition: globals.c:111
char my_exec_path[MAXPGPATH]
Definition: globals.c:75
void SetConfigOption(const char *name, const char *value, GucContext context, GucSource source)
Definition: guc.c:8141
bool SelectConfigFiles(const char *userDoption, const char *progname)
Definition: guc.c:5880
void ParseLongOption(const char *string, char **name, char **value)
Definition: guc.c:11040
void InitializeGUCOptions(void)
Definition: guc.c:5657
const char * GetConfigOption(const char *name, bool missing_ok, bool restrict_privileged)
Definition: guc.c:8165
int GetConfigOptionFlags(const char *name, bool missing_ok)
Definition: guc.c:8260
char * external_pid_file
Definition: guc.c:619
#define GUC_RUNTIME_COMPUTED
Definition: guc.h:235
@ PGC_S_ARGV
Definition: guc.h:110
@ PGC_POSTMASTER
Definition: guc.h:71
bool load_ident(void)
Definition: hba.c:3033
bool load_hba(void)
Definition: hba.c:2239
#define free(a)
Definition: header.h:65
static struct @142 value
static bool success
Definition: initdb.c:167
void on_proc_exit(pg_on_exit_callback function, Datum arg)
Definition: ipc.c:305
void InitializeShmemGUCs(void)
Definition: ipci.c:324
void ApplyLauncherRegister(void)
Definition: launcher.c:707
Assert(fmt[strlen(fmt) - 1] !='\n')
void list_free(List *list)
Definition: list.c:1505
void list_free_deep(List *list)
Definition: list.c:1519
const char * progname
Definition: main.c:46
char * pstrdup(const char *in)
Definition: mcxt.c:1299
void pfree(void *pointer)
Definition: mcxt.c:1169
MemoryContext TopMemoryContext
Definition: mcxt.c:48
MemoryContext PostmasterContext
Definition: mcxt.c:50
#define AllocSetContextCreate
Definition: memutils.h:173
#define ALLOCSET_DEFAULT_SIZES
Definition: memutils.h:195
void ChangeToDataDir(void)
Definition: miscinit.c:435
void AddToDataDirLockFile(int target_line, const char *str)
Definition: miscinit.c:1348
void process_shared_preload_libraries(void)
Definition: miscinit.c:1676
void checkDataDir(void)
Definition: miscinit.c:321
void CreateDataDirLockFile(bool amPostmaster)
Definition: miscinit.c:1292
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
#define pg_hton16(x)
Definition: pg_bswap.h:120
#define PG_TEMP_FILES_DIR
Definition: pg_checksums.c:62
int getopt(int nargc, char *const *nargv, const char *ostr)
Definition: getopt.c:71
int optind
Definition: getopt.c:50
char * optarg
Definition: getopt.c:52
int opterr
Definition: getopt.c:49
#define lfirst(lc)
Definition: pg_list.h:169
#define NIL
Definition: pg_list.h:65
static void static void status(const char *fmt,...) pg_attribute_printf(1
Definition: pg_regress.c:229
void pgstat_init(void)
Definition: pgstat.c:395
#define PM_STATUS_STARTING
Definition: pidfile.h:51
#define LOCK_FILE_LINE_LISTEN_ADDR
Definition: pidfile.h:42
#define LOCK_FILE_LINE_PM_STATUS
Definition: pidfile.h:44
#define LOCK_FILE_LINE_SOCKET_DIR
Definition: pidfile.h:41
#define strerror
Definition: port.h:238
#define fprintf
Definition: port.h:229
void set_debug_options(int debug_flag, GucContext context, GucSource source)
Definition: postgres.c:3565
CommandDest whereToSendOutput
Definition: postgres.c:93
bool set_plan_disabling_options(const char *arg, GucContext context, GucSource source)
Definition: postgres.c:3594
static const char * userDoption
Definition: postgres.c:173
const char * get_stats_option_name(const char *arg)
Definition: postgres.c:3636
pg_stack_base_t set_stack_base(void)
Definition: postgres.c:3417
void InitializeMaxBackends(void)
Definition: postinit.c:496
static void ExitPostmaster(int status) pg_attribute_noreturn()
Definition: postmaster.c:5190
static void maybe_start_bgworkers(void)
Definition: postmaster.c:6050
static void CloseServerPorts(int status, Datum arg)
Definition: postmaster.c:1489
@ PM_STARTUP
Definition: postmaster.c:325
static void InitPostmasterDeathWatchHandle(void)
Definition: postmaster.c:6651
static void pmdie(SIGNAL_ARGS)
Definition: postmaster.c:2843
void InitProcessGlobals(void)
Definition: postmaster.c:2701
static void reset_shared(void)
Definition: postmaster.c:2744
static int ServerLoop(void)
Definition: postmaster.c:1718
int PostPortNumber
Definition: postmaster.c:201
static void checkControlFile(void)
Definition: postmaster.c:1591
#define StartupDataBase()
Definition: postmaster.c:555
bool enable_bonjour
Definition: postmaster.c:244
static int SendStop
Definition: postmaster.c:232
static pid_t CheckpointerPID
Definition: postmaster.c:252
static pid_t BgWriterPID
Definition: postmaster.c:251
char * Unix_socket_directories
Definition: postmaster.c:204
static bool CreateOptsFile(int argc, char *argv[], char *fullprogname)
Definition: postmaster.c:5709
static void sigusr1_handler(SIGNAL_ARGS)
Definition: postmaster.c:5223
static void getInstallationPaths(const char *argv0)
Definition: postmaster.c:1537
static bool Reinit
Definition: postmaster.c:231
#define StartCheckpointer()
Definition: postmaster.c:558
@ STARTUP_RUNNING
Definition: postmaster.c:264
static void unlink_external_pid_file(int status, Datum arg)
Definition: postmaster.c:1525
#define StartBackgroundWriter()
Definition: postmaster.c:557
static StartupStatusEnum StartupStatus
Definition: postmaster.c:269
static void reaper(SIGNAL_ARGS)
Definition: postmaster.c:2995
static void dummy_handler(SIGNAL_ARGS)
Definition: postmaster.c:5417
static pid_t StartupPID
Definition: postmaster.c:250
bool EnableSSL
Definition: postmaster.c:235
static PMState pmState
Definition: postmaster.c:339
char * ListenAddresses
Definition: postmaster.c:207
char * bonjour_name
Definition: postmaster.c:245
static void SIGHUP_handler(SIGNAL_ARGS)
Definition: postmaster.c:2761
int ReservedBackends
Definition: postmaster.c:218
static pid_t SysLoggerPID
Definition: postmaster.c:258
int StreamServerPort(int family, const char *hostName, unsigned short portNumber, const char *unixSocketDir, pgsocket ListenSocket[], int MaxListen)
Definition: pqcomm.c:333
#define PG_SETMASK(mask)
Definition: pqsignal.h:19
char ** environ
void pgwin32_signal_initialize(void)
Definition: signal.c:79
Definition: pg_list.h:51
void RemoveLogrotateSignalFiles(void)
Definition: syslogger.c:1636
int SysLogger_Start(void)
Definition: syslogger.c:567
#define LOG_METAINFO_DATAFILE
Definition: syslogger.h:100
bool SplitDirectoriesString(char *rawstring, char separator, List **namelist)
Definition: varlena.c:3881
bool SplitGUCList(char *rawstring, char separator, List **namelist)
Definition: varlena.c:4002
#define S_IROTH
Definition: win32_port.h:312
#define SIGCHLD
Definition: win32_port.h:177
#define SIGHUP
Definition: win32_port.h:167
#define S_IRGRP
Definition: win32_port.h:300
#define SIGPIPE
Definition: win32_port.h:172
#define SIGQUIT
Definition: win32_port.h:168
#define S_IRUSR
Definition: win32_port.h:288
#define SIGUSR1
Definition: win32_port.h:179
#define SIGALRM
Definition: win32_port.h:173
#define SIGUSR2
Definition: win32_port.h:180
#define SIG_IGN
Definition: win32_port.h:164
#define S_IWUSR
Definition: win32_port.h:291
int XLogArchiveMode
Definition: xlog.c:100
int wal_level
Definition: xlog.c:112
void LocalProcessControlFile(bool reset)
Definition: xlog.c:5181
void RemovePromoteSignalFiles(void)
Definition: xlog.c:13197
@ ARCHIVE_MODE_OFF
Definition: xlog.h:112
@ WAL_LEVEL_MINIMAL
Definition: xlog.h:121

References AddToDataDirLockFile(), ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, ApplyLauncherRegister(), ARCHIVE_MODE_OFF, Assert(), autovac_init(), BgWriterPID, BlockSig, bonjour_name, ChangeToDataDir(), checkControlFile(), checkDataDir(), CheckDateTokenTables(), CheckpointerPID, CloseServerPorts(), CreateDataDirLockFile(), CreateOptsFile(), DEBUG3, DestNone, dummy_handler(), enable_bonjour, EnableSSL, environ, ereport, errcode(), errcode_for_file_access(), errhint(), errmsg(), errmsg_internal(), ERROR, ExitPostmaster(), external_pid_file, FATAL, fprintf, free, get_stats_option_name(), GetConfigOption(), GetConfigOptionFlags(), GetCurrentTimestamp(), getInstallationPaths(), getopt(), GUC_RUNTIME_COMPUTED, i, InitializeGUCOptions(), InitializeMaxBackends(), InitializeShmemGUCs(), InitPostmasterDeathWatchHandle(), InitProcessGlobals(), IsBinaryUpgrade, IsPostmasterEnvironment, lfirst, list_free(), list_free_deep(), ListenAddresses, ListenSocket, load_hba(), load_ident(), LocalProcessControlFile(), LOCK_FILE_LINE_LISTEN_ADDR, LOCK_FILE_LINE_PM_STATUS, LOCK_FILE_LINE_SOCKET_DIR, LOG, Log_destination, LOG_DESTINATION_STDERR, Log_destination_string, LOG_METAINFO_DATAFILE, max_wal_senders, MaxConnections, MAXLISTEN, maybe_start_bgworkers(), MemoryContextSwitchTo(), my_exec_path, MyProcPid, name, NIL, on_proc_exit(), optarg, opterr, optind, ParseLongOption(), pfree(), pg_hton16, PG_MODE_MASK_OWNER, PG_SETMASK, PG_TEMP_FILES_DIR, PGC_POSTMASTER, PGC_S_ARGV, PGINVALID_SOCKET, PgStartTime, pgstat_init(), pgwin32_signal_initialize(), PM_STARTUP, PM_STATUS_STARTING, pmdie(), pmState, PostmasterContext, PostmasterPid, PostPortNumber, pqinitmask(), pqsignal_pm(), process_shared_preload_libraries(), progname, pstrdup(), reaper(), Reinit, RemoveLogrotateSignalFiles(), RemovePgTempFiles(), RemovePgTempFilesInDir(), RemovePromoteSignalFiles(), ReservedBackends, reset_shared(), S_IRGRP, S_IROTH, S_IRUSR, S_IWUSR, secure_initialize(), SelectConfigFiles(), SendStop, ServerLoop(), set_debug_options(), set_max_safe_fds(), set_plan_disabling_options(), set_stack_base(), SetConfigOption(), SIG_IGN, SIGALRM, SIGCHLD, SIGHUP, SIGHUP_handler(), SIGPIPE, SIGQUIT, SIGUSR1, sigusr1_handler(), SIGUSR2, SplitDirectoriesString(), SplitGUCList(), StartBackgroundWriter, StartCheckpointer, STARTUP_RUNNING, StartupDataBase, StartupPID, StartupStatus, status(), STATUS_OK, StreamServerPort(), strerror, success, SysLogger_Start(), SysLoggerPID, TopMemoryContext, Unix_socket_directories, unlink_external_pid_file(), userDoption, value, wal_level, WAL_LEVEL_MINIMAL, WARNING, whereToSendOutput, write_stderr, and XLogArchiveMode.

Referenced by main().

◆ PostmasterMarkPIDForWorkerNotify()

bool PostmasterMarkPIDForWorkerNotify ( int  pid)

Definition at line 6169 of file postmaster.c.

6170 {
6171  dlist_iter iter;
6172  Backend *bp;
6173 
6174  dlist_foreach(iter, &BackendList)
6175  {
6176  bp = dlist_container(Backend, elem, iter.cur);
6177  if (bp->pid == pid)
6178  {
6179  bp->bgworker_notify = true;
6180  return true;
6181  }
6182  }
6183  return false;
6184 }
#define dlist_foreach(iter, lhead)
Definition: ilist.h:526
#define dlist_container(type, membername, ptr)
Definition: ilist.h:496
static dlist_head BackendList
Definition: postmaster.c:190
bool bgworker_notify
Definition: postmaster.c:186
pid_t pid
Definition: postmaster.c:181
dlist_node * cur
Definition: ilist.h:161

References BackendList, bkend::bgworker_notify, dlist_iter::cur, dlist_container, dlist_foreach, and bkend::pid.

Referenced by BackgroundWorkerStateChange().

Variable Documentation

◆ AuthenticationTimeout

int AuthenticationTimeout
extern

Definition at line 238 of file postmaster.c.

Referenced by BackendInitialize(), and PerformAuthentication().

◆ bonjour_name

char* bonjour_name
extern

Definition at line 245 of file postmaster.c.

Referenced by PostmasterMain().

◆ ClientAuthInProgress

◆ enable_bonjour

bool enable_bonjour
extern

Definition at line 244 of file postmaster.c.

Referenced by PostmasterMain().

◆ EnableSSL

bool EnableSSL
extern

Definition at line 235 of file postmaster.c.

Referenced by parse_hba_line(), PostmasterMain(), and SIGHUP_handler().

◆ ListenAddresses

char* ListenAddresses
extern

Definition at line 207 of file postmaster.c.

Referenced by PostmasterMain().

◆ Log_connections

bool Log_connections
extern

Definition at line 241 of file postmaster.c.

Referenced by BackendInitialize(), PerformAuthentication(), and set_authn_id().

◆ log_hostname

bool log_hostname
extern

Definition at line 240 of file postmaster.c.

Referenced by BackendInitialize().

◆ postmaster_alive_fds

int postmaster_alive_fds[2]
extern

◆ PostPortNumber

PGDLLIMPORT int PostPortNumber
extern

Definition at line 201 of file postmaster.c.

Referenced by CreateLockFile(), and PostmasterMain().

◆ PreAuthDelay

int PreAuthDelay
extern

Definition at line 237 of file postmaster.c.

Referenced by BackendInitialize().

◆ progname

◆ remove_temp_files_after_crash

bool remove_temp_files_after_crash
extern

Definition at line 247 of file postmaster.c.

Referenced by PostmasterStateMachine().

◆ ReservedBackends

int ReservedBackends
extern

Definition at line 218 of file postmaster.c.

Referenced by InitPostgres(), and PostmasterMain().

◆ restart_after_crash

bool restart_after_crash
extern

Definition at line 246 of file postmaster.c.

Referenced by PostmasterStateMachine().

◆ Unix_socket_directories

char* Unix_socket_directories
extern

Definition at line 204 of file postmaster.c.

Referenced by PostmasterMain().

◆ Unix_socket_group

char* Unix_socket_group
extern

Definition at line 109 of file pqcomm.c.

◆ Unix_socket_permissions

int Unix_socket_permissions
extern

Definition at line 108 of file pqcomm.c.

Referenced by show_unix_socket_permissions().