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
 
int postmaster_alive_fds [2]
 
PGDLLIMPORT const char * progname
 

Macro Definition Documentation

◆ MAX_BACKENDS

◆ POSTMASTER_FD_OWN

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

Definition at line 44 of file postmaster.h.

Referenced by ClosePostmasterPorts().

◆ POSTMASTER_FD_WATCH

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

Definition at line 42 of file postmaster.h.

Referenced by AddWaitEventToSet(), InitPostmasterDeathWatchHandle(), and PostmasterIsAliveInternal().

Function Documentation

◆ ClosePostmasterPorts()

void ClosePostmasterPorts ( bool  am_syslogger)

Definition at line 2512 of file postmaster.c.

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

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

2513 {
2514  int i;
2515 
2516 #ifndef WIN32
2517 
2518  /*
2519  * Close the write end of postmaster death watch pipe. It's important to
2520  * do this as early as possible, so that if postmaster dies, others won't
2521  * think that it's still running because we're holding the pipe open.
2522  */
2524  ereport(FATAL,
2526  errmsg_internal("could not close postmaster death monitoring pipe in child process: %m")));
2528 #endif
2529 
2530  /* Close the listen sockets */
2531  for (i = 0; i < MAXLISTEN; i++)
2532  {
2533  if (ListenSocket[i] != PGINVALID_SOCKET)
2534  {
2537  }
2538  }
2539 
2540  /* If using syslogger, close the read side of the pipe */
2541  if (!am_syslogger)
2542  {
2543 #ifndef WIN32
2544  if (syslogPipe[0] >= 0)
2545  close(syslogPipe[0]);
2546  syslogPipe[0] = -1;
2547 #else
2548  if (syslogPipe[0])
2549  CloseHandle(syslogPipe[0]);
2550  syslogPipe[0] = 0;
2551 #endif
2552  }
2553 
2554 #ifdef USE_BONJOUR
2555  /* If using Bonjour, close the connection to the mDNS daemon */
2556  if (bonjour_sdref)
2557  close(DNSServiceRefSockFD(bonjour_sdref));
2558 #endif
2559 }
void StreamClose(pgsocket sock)
Definition: pqcomm.c:845
#define FATAL
Definition: elog.h:52
bool am_syslogger
Definition: syslogger.c:80
#define POSTMASTER_FD_OWN
Definition: postmaster.h:44
int errcode_for_file_access(void)
Definition: elog.c:593
#define ereport(elevel, rest)
Definition: elog.h:141
int postmaster_alive_fds[2]
Definition: postmaster.c:557
static pgsocket ListenSocket[MAXLISTEN]
Definition: postmaster.c:218
#define PGINVALID_SOCKET
Definition: port.h:33
int errmsg_internal(const char *fmt,...)
Definition: elog.c:814
int i
#define close(a)
Definition: win32.h:12
#define MAXLISTEN
Definition: postmaster.c:217
int syslogPipe[2]
Definition: syslogger.c:118

◆ InitProcessGlobals()

void InitProcessGlobals ( void  )

Definition at line 2568 of file postmaster.c.

References GetCurrentTimestamp(), MyProcPid, MyStartTime, MyStartTimestamp, pg_strong_random(), srandom(), and timestamptz_to_time_t().

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

2569 {
2570  unsigned int rseed;
2571 
2572  MyProcPid = getpid();
2575 
2576  /*
2577  * Set a different seed for random() in every process. We want something
2578  * unpredictable, so if possible, use high-quality random bits for the
2579  * seed. Otherwise, fall back to a seed based on timestamp and PID.
2580  */
2581  if (!pg_strong_random(&rseed, sizeof(rseed)))
2582  {
2583  /*
2584  * Since PIDs and timestamps tend to change more frequently in their
2585  * least significant bits, shift the timestamp left to allow a larger
2586  * total number of seeds in a given time period. Since that would
2587  * leave only 20 bits of the timestamp that cycle every ~1 second,
2588  * also mix in some higher bits.
2589  */
2590  rseed = ((uint64) MyProcPid) ^
2591  ((uint64) MyStartTimestamp << 12) ^
2592  ((uint64) MyStartTimestamp >> 20);
2593  }
2594  srandom(rseed);
2595 }
int MyProcPid
Definition: globals.c:40
TimestampTz GetCurrentTimestamp(void)
Definition: timestamp.c:1569
pg_time_t MyStartTime
Definition: globals.c:41
pg_time_t timestamptz_to_time_t(TimestampTz t)
Definition: timestamp.c:1711
TimestampTz MyStartTimestamp
Definition: globals.c:42
bool pg_strong_random(void *buf, size_t len)
void srandom(unsigned int seed)
Definition: srandom.c:22

◆ MaxLivePostmasterChildren()

int MaxLivePostmasterChildren ( void  )

Definition at line 5600 of file postmaster.c.

References autovacuum_max_workers, max_wal_senders, max_worker_processes, and MaxConnections.

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

5601 {
5602  return 2 * (MaxConnections + autovacuum_max_workers + 1 +
5604 }
int max_wal_senders
Definition: walsender.c:120
int MaxConnections
Definition: globals.c:132
int autovacuum_max_workers
Definition: autovacuum.c:114
int max_worker_processes
Definition: globals.c:133

◆ PostmasterMain()

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

Definition at line 567 of file postmaster.c.

References AddToDataDirLockFile(), ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, ApplyLauncherRegister(), ARCHIVE_MODE_OFF, Assert, autovac_init(), BlockSig, bonjour_name, ChangeToDataDir(), checkControlFile(), checkDataDir(), CheckDateTokenTables(), CloseServerPorts(), CreateDataDirLockFile(), CreateOptsFile(), DEBUG3, DestNone, dummy_handler(), elog, enable_bonjour, EnableSSL, environ, ereport, errcode(), errcode_for_file_access(), errhint(), errmsg(), errmsg_internal(), ERROR, ExitPostmaster(), external_pid_file, ExtraOptions, FATAL, fprintf, free, get_stats_option_name(), GetConfigOption(), GetCurrentTimestamp(), getInstallationPaths(), getopt(), i, InitializeGUCOptions(), InitializeMaxBackends(), 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, PGC_POSTMASTER, PGC_S_ARGV, PGINVALID_SOCKET, PgStartTime, pgstat_init(), PM_STARTUP, PM_STATUS_STARTING, pmdie(), pmState, PostmasterContext, PostmasterPid, PostPortNumber, pqinitmask(), pqsignal(), pqsignal_no_restart(), process_shared_preload_libraries(), progname, pstrdup(), reaper(), Reinit, RemoveLogrotateSignalFiles(), RemovePgTempFiles(), 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, snprintf, SplitDirectoriesString(), SplitIdentifierString(), 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().

568 {
569  int opt;
570  int status;
571  char *userDoption = NULL;
572  bool listen_addr_saved = false;
573  int i;
574  char *output_config_variable = NULL;
575 
577 
579 
581 
582  /*
583  * We should not be creating any files or directories before we check the
584  * data directory (see checkDataDir()), but just in case set the umask to
585  * the most restrictive (owner-only) permissions.
586  *
587  * checkDataDir() will reset the umask based on the data directory
588  * permissions.
589  */
590  umask(PG_MODE_MASK_OWNER);
591 
592  /*
593  * By default, palloc() requests in the postmaster will be allocated in
594  * the PostmasterContext, which is space that can be recycled by backends.
595  * Allocated data that needs to be available to backends should be
596  * allocated in TopMemoryContext.
597  */
599  "Postmaster",
602 
603  /* Initialize paths to installation files */
604  getInstallationPaths(argv[0]);
605 
606  /*
607  * Set up signal handlers for the postmaster process.
608  *
609  * In the postmaster, we want to install non-ignored handlers *without*
610  * SA_RESTART. This is because they'll be blocked at all times except
611  * when ServerLoop is waiting for something to happen, and during that
612  * window, we want signals to exit the select(2) wait so that ServerLoop
613  * can respond if anything interesting happened. On some platforms,
614  * signals marked SA_RESTART would not cause the select() wait to end.
615  * Child processes will generally want SA_RESTART, but we expect them to
616  * set up their own handlers before unblocking signals.
617  *
618  * CAUTION: when changing this list, check for side-effects on the signal
619  * handling setup of child processes. See tcop/postgres.c,
620  * bootstrap/bootstrap.c, postmaster/bgwriter.c, postmaster/walwriter.c,
621  * postmaster/autovacuum.c, postmaster/pgarch.c, postmaster/pgstat.c,
622  * postmaster/syslogger.c, postmaster/bgworker.c and
623  * postmaster/checkpointer.c.
624  */
625  pqinitmask();
627 
628  pqsignal_no_restart(SIGHUP, SIGHUP_handler); /* reread config file and
629  * have children do same */
630  pqsignal_no_restart(SIGINT, pmdie); /* send SIGTERM and shut down */
631  pqsignal_no_restart(SIGQUIT, pmdie); /* send SIGQUIT and die */
632  pqsignal_no_restart(SIGTERM, pmdie); /* wait for children and shut down */
633  pqsignal(SIGALRM, SIG_IGN); /* ignored */
634  pqsignal(SIGPIPE, SIG_IGN); /* ignored */
635  pqsignal_no_restart(SIGUSR1, sigusr1_handler); /* message from child
636  * process */
637  pqsignal_no_restart(SIGUSR2, dummy_handler); /* unused, reserve for
638  * children */
639  pqsignal_no_restart(SIGCHLD, reaper); /* handle child termination */
640 
641  /*
642  * No other place in Postgres should touch SIGTTIN/SIGTTOU handling. We
643  * ignore those signals in a postmaster environment, so that there is no
644  * risk of a child process freezing up due to writing to stderr. But for
645  * a standalone backend, their default handling is reasonable. Hence, all
646  * child processes should just allow the inherited settings to stand.
647  */
648 #ifdef SIGTTIN
649  pqsignal(SIGTTIN, SIG_IGN); /* ignored */
650 #endif
651 #ifdef SIGTTOU
652  pqsignal(SIGTTOU, SIG_IGN); /* ignored */
653 #endif
654 
655  /* ignore SIGXFSZ, so that ulimit violations work like disk full */
656 #ifdef SIGXFSZ
657  pqsignal(SIGXFSZ, SIG_IGN); /* ignored */
658 #endif
659 
660  /*
661  * Options setup
662  */
664 
665  opterr = 1;
666 
667  /*
668  * Parse command-line options. CAUTION: keep this in sync with
669  * tcop/postgres.c (the option sets should not conflict) and with the
670  * common help() function in main/main.c.
671  */
672  while ((opt = getopt(argc, argv, "B:bc:C:D:d:EeFf:h:ijk:lN:nOo:Pp:r:S:sTt:W:-:")) != -1)
673  {
674  switch (opt)
675  {
676  case 'B':
677  SetConfigOption("shared_buffers", optarg, PGC_POSTMASTER, PGC_S_ARGV);
678  break;
679 
680  case 'b':
681  /* Undocumented flag used for binary upgrades */
682  IsBinaryUpgrade = true;
683  break;
684 
685  case 'C':
686  output_config_variable = strdup(optarg);
687  break;
688 
689  case 'D':
690  userDoption = strdup(optarg);
691  break;
692 
693  case 'd':
695  break;
696 
697  case 'E':
698  SetConfigOption("log_statement", "all", PGC_POSTMASTER, PGC_S_ARGV);
699  break;
700 
701  case 'e':
702  SetConfigOption("datestyle", "euro", PGC_POSTMASTER, PGC_S_ARGV);
703  break;
704 
705  case 'F':
706  SetConfigOption("fsync", "false", PGC_POSTMASTER, PGC_S_ARGV);
707  break;
708 
709  case 'f':
711  {
712  write_stderr("%s: invalid argument for option -f: \"%s\"\n",
713  progname, optarg);
714  ExitPostmaster(1);
715  }
716  break;
717 
718  case 'h':
719  SetConfigOption("listen_addresses", optarg, PGC_POSTMASTER, PGC_S_ARGV);
720  break;
721 
722  case 'i':
723  SetConfigOption("listen_addresses", "*", PGC_POSTMASTER, PGC_S_ARGV);
724  break;
725 
726  case 'j':
727  /* only used by interactive backend */
728  break;
729 
730  case 'k':
731  SetConfigOption("unix_socket_directories", optarg, PGC_POSTMASTER, PGC_S_ARGV);
732  break;
733 
734  case 'l':
735  SetConfigOption("ssl", "true", PGC_POSTMASTER, PGC_S_ARGV);
736  break;
737 
738  case 'N':
739  SetConfigOption("max_connections", optarg, PGC_POSTMASTER, PGC_S_ARGV);
740  break;
741 
742  case 'n':
743  /* Don't reinit shared mem after abnormal exit */
744  Reinit = false;
745  break;
746 
747  case 'O':
748  SetConfigOption("allow_system_table_mods", "true", PGC_POSTMASTER, PGC_S_ARGV);
749  break;
750 
751  case 'o':
752  /* Other options to pass to the backend on the command line */
754  sizeof(ExtraOptions) - strlen(ExtraOptions),
755  " %s", optarg);
756  break;
757 
758  case 'P':
759  SetConfigOption("ignore_system_indexes", "true", PGC_POSTMASTER, PGC_S_ARGV);
760  break;
761 
762  case 'p':
764  break;
765 
766  case 'r':
767  /* only used by single-user backend */
768  break;
769 
770  case 'S':
772  break;
773 
774  case 's':
775  SetConfigOption("log_statement_stats", "true", PGC_POSTMASTER, PGC_S_ARGV);
776  break;
777 
778  case 'T':
779 
780  /*
781  * In the event that some backend dumps core, send SIGSTOP,
782  * rather than SIGQUIT, to all its peers. This lets the wily
783  * post_hacker collect core dumps from everyone.
784  */
785  SendStop = true;
786  break;
787 
788  case 't':
789  {
790  const char *tmp = get_stats_option_name(optarg);
791 
792  if (tmp)
793  {
795  }
796  else
797  {
798  write_stderr("%s: invalid argument for option -t: \"%s\"\n",
799  progname, optarg);
800  ExitPostmaster(1);
801  }
802  break;
803  }
804 
805  case 'W':
806  SetConfigOption("post_auth_delay", optarg, PGC_POSTMASTER, PGC_S_ARGV);
807  break;
808 
809  case 'c':
810  case '-':
811  {
812  char *name,
813  *value;
814 
815  ParseLongOption(optarg, &name, &value);
816  if (!value)
817  {
818  if (opt == '-')
819  ereport(ERROR,
820  (errcode(ERRCODE_SYNTAX_ERROR),
821  errmsg("--%s requires a value",
822  optarg)));
823  else
824  ereport(ERROR,
825  (errcode(ERRCODE_SYNTAX_ERROR),
826  errmsg("-c %s requires a value",
827  optarg)));
828  }
829 
831  free(name);
832  if (value)
833  free(value);
834  break;
835  }
836 
837  default:
838  write_stderr("Try \"%s --help\" for more information.\n",
839  progname);
840  ExitPostmaster(1);
841  }
842  }
843 
844  /*
845  * Postmaster accepts no non-option switch arguments.
846  */
847  if (optind < argc)
848  {
849  write_stderr("%s: invalid argument: \"%s\"\n",
850  progname, argv[optind]);
851  write_stderr("Try \"%s --help\" for more information.\n",
852  progname);
853  ExitPostmaster(1);
854  }
855 
856  /*
857  * Locate the proper configuration files and data directory, and read
858  * postgresql.conf for the first time.
859  */
860  if (!SelectConfigFiles(userDoption, progname))
861  ExitPostmaster(2);
862 
863  if (output_config_variable != NULL)
864  {
865  /*
866  * "-C guc" was specified, so print GUC's value and exit. No extra
867  * permission check is needed because the user is reading inside the
868  * data dir.
869  */
870  const char *config_val = GetConfigOption(output_config_variable,
871  false, false);
872 
873  puts(config_val ? config_val : "");
874  ExitPostmaster(0);
875  }
876 
877  /* Verify that DataDir looks reasonable */
878  checkDataDir();
879 
880  /* Check that pg_control exists */
882 
883  /* And switch working directory into it */
884  ChangeToDataDir();
885 
886  /*
887  * Check for invalid combinations of GUC settings.
888  */
890  {
891  write_stderr("%s: superuser_reserved_connections (%d) must be less than max_connections (%d)\n",
892  progname,
894  ExitPostmaster(1);
895  }
897  ereport(ERROR,
898  (errmsg("WAL archival cannot be enabled when wal_level is \"minimal\"")));
900  ereport(ERROR,
901  (errmsg("WAL streaming (max_wal_senders > 0) requires wal_level \"replica\" or \"logical\"")));
902 
903  /*
904  * Other one-time internal sanity checks can go here, if they are fast.
905  * (Put any slow processing further down, after postmaster.pid creation.)
906  */
907  if (!CheckDateTokenTables())
908  {
909  write_stderr("%s: invalid datetoken tables, please fix\n", progname);
910  ExitPostmaster(1);
911  }
912 
913  /*
914  * Now that we are done processing the postmaster arguments, reset
915  * getopt(3) library so that it will work correctly in subprocesses.
916  */
917  optind = 1;
918 #ifdef HAVE_INT_OPTRESET
919  optreset = 1; /* some systems need this too */
920 #endif
921 
922  /* For debugging: display postmaster environment */
923  {
924  extern char **environ;
925  char **p;
926 
927  ereport(DEBUG3,
928  (errmsg_internal("%s: PostmasterMain: initial environment dump:",
929  progname)));
930  ereport(DEBUG3,
931  (errmsg_internal("-----------------------------------------")));
932  for (p = environ; *p; ++p)
933  ereport(DEBUG3,
934  (errmsg_internal("\t%s", *p)));
935  ereport(DEBUG3,
936  (errmsg_internal("-----------------------------------------")));
937  }
938 
939  /*
940  * Create lockfile for data directory.
941  *
942  * We want to do this before we try to grab the input sockets, because the
943  * data directory interlock is more reliable than the socket-file
944  * interlock (thanks to whoever decided to put socket files in /tmp :-().
945  * For the same reason, it's best to grab the TCP socket(s) before the
946  * Unix socket(s).
947  *
948  * Also note that this internally sets up the on_proc_exit function that
949  * is responsible for removing both data directory and socket lockfiles;
950  * so it must happen before opening sockets so that at exit, the socket
951  * lockfiles go away after CloseServerPorts runs.
952  */
953  CreateDataDirLockFile(true);
954 
955  /*
956  * Read the control file (for error checking and config info).
957  *
958  * Since we verify the control file's CRC, this has a useful side effect
959  * on machines where we need a run-time test for CRC support instructions.
960  * The postmaster will do the test once at startup, and then its child
961  * processes will inherit the correct function pointer and not need to
962  * repeat the test.
963  */
965 
966  /*
967  * Initialize SSL library, if specified.
968  */
969 #ifdef USE_SSL
970  if (EnableSSL)
971  {
972  (void) secure_initialize(true);
973  LoadedSSL = true;
974  }
975 #endif
976 
977  /*
978  * Register the apply launcher. Since it registers a background worker,
979  * it needs to be called before InitializeMaxBackends(), and it's probably
980  * a good idea to call it before any modules had chance to take the
981  * background worker slots.
982  */
984 
985  /*
986  * process any libraries that should be preloaded at postmaster start
987  */
989 
990  /*
991  * Now that loadable modules have had their chance to register background
992  * workers, calculate MaxBackends.
993  */
995 
996  /* Report server startup in log */
997  ereport(LOG,
998  (errmsg("starting %s", PG_VERSION_STR)));
999 
1000  /*
1001  * Establish input sockets.
1002  *
1003  * First, mark them all closed, and set up an on_proc_exit function that's
1004  * charged with closing the sockets again at postmaster shutdown.
1005  */
1006  for (i = 0; i < MAXLISTEN; i++)
1008 
1010 
1011  if (ListenAddresses)
1012  {
1013  char *rawstring;
1014  List *elemlist;
1015  ListCell *l;
1016  int success = 0;
1017 
1018  /* Need a modifiable copy of ListenAddresses */
1019  rawstring = pstrdup(ListenAddresses);
1020 
1021  /* Parse string into list of hostnames */
1022  if (!SplitIdentifierString(rawstring, ',', &elemlist))
1023  {
1024  /* syntax error in list */
1025  ereport(FATAL,
1026  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1027  errmsg("invalid list syntax in parameter \"%s\"",
1028  "listen_addresses")));
1029  }
1030 
1031  foreach(l, elemlist)
1032  {
1033  char *curhost = (char *) lfirst(l);
1034 
1035  if (strcmp(curhost, "*") == 0)
1036  status = StreamServerPort(AF_UNSPEC, NULL,
1037  (unsigned short) PostPortNumber,
1038  NULL,
1040  else
1041  status = StreamServerPort(AF_UNSPEC, curhost,
1042  (unsigned short) PostPortNumber,
1043  NULL,
1044  ListenSocket, MAXLISTEN);
1045 
1046  if (status == STATUS_OK)
1047  {
1048  success++;
1049  /* record the first successful host addr in lockfile */
1050  if (!listen_addr_saved)
1051  {
1053  listen_addr_saved = true;
1054  }
1055  }
1056  else
1057  ereport(WARNING,
1058  (errmsg("could not create listen socket for \"%s\"",
1059  curhost)));
1060  }
1061 
1062  if (!success && elemlist != NIL)
1063  ereport(FATAL,
1064  (errmsg("could not create any TCP/IP sockets")));
1065 
1066  list_free(elemlist);
1067  pfree(rawstring);
1068  }
1069 
1070 #ifdef USE_BONJOUR
1071  /* Register for Bonjour only if we opened TCP socket(s) */
1072  if (enable_bonjour && ListenSocket[0] != PGINVALID_SOCKET)
1073  {
1074  DNSServiceErrorType err;
1075 
1076  /*
1077  * We pass 0 for interface_index, which will result in registering on
1078  * all "applicable" interfaces. It's not entirely clear from the
1079  * DNS-SD docs whether this would be appropriate if we have bound to
1080  * just a subset of the available network interfaces.
1081  */
1082  err = DNSServiceRegister(&bonjour_sdref,
1083  0,
1084  0,
1085  bonjour_name,
1086  "_postgresql._tcp.",
1087  NULL,
1088  NULL,
1090  0,
1091  NULL,
1092  NULL,
1093  NULL);
1094  if (err != kDNSServiceErr_NoError)
1095  elog(LOG, "DNSServiceRegister() failed: error code %ld",
1096  (long) err);
1097 
1098  /*
1099  * We don't bother to read the mDNS daemon's reply, and we expect that
1100  * it will automatically terminate our registration when the socket is
1101  * closed at postmaster termination. So there's nothing more to be
1102  * done here. However, the bonjour_sdref is kept around so that
1103  * forked children can close their copies of the socket.
1104  */
1105  }
1106 #endif
1107 
1108 #ifdef HAVE_UNIX_SOCKETS
1110  {
1111  char *rawstring;
1112  List *elemlist;
1113  ListCell *l;
1114  int success = 0;
1115 
1116  /* Need a modifiable copy of Unix_socket_directories */
1117  rawstring = pstrdup(Unix_socket_directories);
1118 
1119  /* Parse string into list of directories */
1120  if (!SplitDirectoriesString(rawstring, ',', &elemlist))
1121  {
1122  /* syntax error in list */
1123  ereport(FATAL,
1124  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1125  errmsg("invalid list syntax in parameter \"%s\"",
1126  "unix_socket_directories")));
1127  }
1128 
1129  foreach(l, elemlist)
1130  {
1131  char *socketdir = (char *) lfirst(l);
1132 
1133  status = StreamServerPort(AF_UNIX, NULL,
1134  (unsigned short) PostPortNumber,
1135  socketdir,
1136  ListenSocket, MAXLISTEN);
1137 
1138  if (status == STATUS_OK)
1139  {
1140  success++;
1141  /* record the first successful Unix socket in lockfile */
1142  if (success == 1)
1144  }
1145  else
1146  ereport(WARNING,
1147  (errmsg("could not create Unix-domain socket in directory \"%s\"",
1148  socketdir)));
1149  }
1150 
1151  if (!success && elemlist != NIL)
1152  ereport(FATAL,
1153  (errmsg("could not create any Unix-domain sockets")));
1154 
1155  list_free_deep(elemlist);
1156  pfree(rawstring);
1157  }
1158 #endif
1159 
1160  /*
1161  * check that we have some socket to listen on
1162  */
1163  if (ListenSocket[0] == PGINVALID_SOCKET)
1164  ereport(FATAL,
1165  (errmsg("no socket created for listening")));
1166 
1167  /*
1168  * If no valid TCP ports, write an empty line for listen address,
1169  * indicating the Unix socket must be used. Note that this line is not
1170  * added to the lock file until there is a socket backing it.
1171  */
1172  if (!listen_addr_saved)
1174 
1175  /*
1176  * Set up shared memory and semaphores.
1177  */
1179 
1180  /*
1181  * Estimate number of openable files. This must happen after setting up
1182  * semaphores, because on some platforms semaphores count as open files.
1183  */
1184  set_max_safe_fds();
1185 
1186  /*
1187  * Set reference point for stack-depth checking.
1188  */
1189  set_stack_base();
1190 
1191  /*
1192  * Initialize pipe (or process handle on Windows) that allows children to
1193  * wake up from sleep on postmaster death.
1194  */
1196 
1197 #ifdef WIN32
1198 
1199  /*
1200  * Initialize I/O completion port used to deliver list of dead children.
1201  */
1202  win32ChildQueue = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 1);
1203  if (win32ChildQueue == NULL)
1204  ereport(FATAL,
1205  (errmsg("could not create I/O completion port for child queue")));
1206 #endif
1207 
1208  /*
1209  * Record postmaster options. We delay this till now to avoid recording
1210  * bogus options (eg, NBuffers too high for available memory).
1211  */
1212  if (!CreateOptsFile(argc, argv, my_exec_path))
1213  ExitPostmaster(1);
1214 
1215 #ifdef EXEC_BACKEND
1216  /* Write out nondefault GUC settings for child processes to use */
1217  write_nondefault_variables(PGC_POSTMASTER);
1218 #endif
1219 
1220  /*
1221  * Write the external PID file if requested
1222  */
1223  if (external_pid_file)
1224  {
1225  FILE *fpidfile = fopen(external_pid_file, "w");
1226 
1227  if (fpidfile)
1228  {
1229  fprintf(fpidfile, "%d\n", MyProcPid);
1230  fclose(fpidfile);
1231 
1232  /* Make PID file world readable */
1233  if (chmod(external_pid_file, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) != 0)
1234  write_stderr("%s: could not change permissions of external PID file \"%s\": %s\n",
1236  }
1237  else
1238  write_stderr("%s: could not write external PID file \"%s\": %s\n",
1240 
1242  }
1243 
1244  /*
1245  * Remove old temporary files. At this point there can be no other
1246  * Postgres processes running in this directory, so this should be safe.
1247  */
1249 
1250  /*
1251  * Forcibly remove the files signaling a standby promotion request.
1252  * Otherwise, the existence of those files triggers a promotion too early,
1253  * whether a user wants that or not.
1254  *
1255  * This removal of files is usually unnecessary because they can exist
1256  * only during a few moments during a standby promotion. However there is
1257  * a race condition: if pg_ctl promote is executed and creates the files
1258  * during a promotion, the files can stay around even after the server is
1259  * brought up to new master. Then, if new standby starts by using the
1260  * backup taken from that master, the files can exist at the server
1261  * startup and should be removed in order to avoid an unexpected
1262  * promotion.
1263  *
1264  * Note that promotion signal files need to be removed before the startup
1265  * process is invoked. Because, after that, they can be used by
1266  * postmaster's SIGUSR1 signal handler.
1267  */
1269 
1270  /* Do the same for logrotate signal file */
1272 
1273  /* Remove any outdated file holding the current log filenames. */
1274  if (unlink(LOG_METAINFO_DATAFILE) < 0 && errno != ENOENT)
1275  ereport(LOG,
1277  errmsg("could not remove file \"%s\": %m",
1279 
1280  /*
1281  * If enabled, start up syslogger collection subprocess
1282  */
1284 
1285  /*
1286  * Reset whereToSendOutput from DestDebug (its starting state) to
1287  * DestNone. This stops ereport from sending log messages to stderr unless
1288  * Log_destination permits. We don't do this until the postmaster is
1289  * fully launched, since startup failures may as well be reported to
1290  * stderr.
1291  *
1292  * If we are in fact disabling logging to stderr, first emit a log message
1293  * saying so, to provide a breadcrumb trail for users who may not remember
1294  * that their logging is configured to go somewhere else.
1295  */
1297  ereport(LOG,
1298  (errmsg("ending log output to stderr"),
1299  errhint("Future log output will go to log destination \"%s\".",
1301 
1303 
1304  /*
1305  * Initialize stats collection subsystem (this does NOT start the
1306  * collector process!)
1307  */
1308  pgstat_init();
1309 
1310  /*
1311  * Initialize the autovacuum subsystem (again, no process start yet)
1312  */
1313  autovac_init();
1314 
1315  /*
1316  * Load configuration files for client authentication.
1317  */
1318  if (!load_hba())
1319  {
1320  /*
1321  * It makes no sense to continue if we fail to load the HBA file,
1322  * since there is no way to connect to the database in this case.
1323  */
1324  ereport(FATAL,
1325  (errmsg("could not load pg_hba.conf")));
1326  }
1327  if (!load_ident())
1328  {
1329  /*
1330  * We can start up without the IDENT file, although it means that you
1331  * cannot log in using any of the authentication methods that need a
1332  * user name mapping. load_ident() already logged the details of error
1333  * to the log.
1334  */
1335  }
1336 
1337 #ifdef HAVE_PTHREAD_IS_THREADED_NP
1338 
1339  /*
1340  * On macOS, libintl replaces setlocale() with a version that calls
1341  * CFLocaleCopyCurrent() when its second argument is "" and every relevant
1342  * environment variable is unset or empty. CFLocaleCopyCurrent() makes
1343  * the process multithreaded. The postmaster calls sigprocmask() and
1344  * calls fork() without an immediate exec(), both of which have undefined
1345  * behavior in a multithreaded program. A multithreaded postmaster is the
1346  * normal case on Windows, which offers neither fork() nor sigprocmask().
1347  */
1348  if (pthread_is_threaded_np() != 0)
1349  ereport(FATAL,
1350  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
1351  errmsg("postmaster became multithreaded during startup"),
1352  errhint("Set the LC_ALL environment variable to a valid locale.")));
1353 #endif
1354 
1355  /*
1356  * Remember postmaster startup time
1357  */
1359 
1360  /*
1361  * Report postmaster status in the postmaster.pid file, to allow pg_ctl to
1362  * see what's happening.
1363  */
1365 
1366  /*
1367  * We're ready to rock and roll...
1368  */
1370  Assert(StartupPID != 0);
1372  pmState = PM_STARTUP;
1373 
1374  /* Some workers may be scheduled to start now */
1376 
1377  status = ServerLoop();
1378 
1379  /*
1380  * ServerLoop probably shouldn't ever return, but if it does, close down.
1381  */
1382  ExitPostmaster(status != STATUS_OK);
1383 
1384  abort(); /* not reached */
1385 }
pg_stack_base_t set_stack_base(void)
Definition: postgres.c:3209
int secure_initialize(bool isServerStart)
Definition: be-secure.c:78
#define NIL
Definition: pg_list.h:65
bool IsPostmasterEnvironment
Definition: globals.c:108
bool EnableSSL
Definition: postmaster.c:236
#define SIGQUIT
Definition: win32_port.h:164
static StartupStatusEnum StartupStatus
Definition: postmaster.c:269
#define S_IRGRP
Definition: win32_port.h:281
#define AllocSetContextCreate
Definition: memutils.h:169
static void unlink_external_pid_file(int status, Datum arg)
Definition: postmaster.c:1428
int MyProcPid
Definition: globals.c:40
int errhint(const char *fmt,...)
Definition: elog.c:974
#define StartupDataBase()
Definition: postmaster.c:541
#define DEBUG3
Definition: elog.h:23
#define SIGUSR1
Definition: win32_port.h:175
TimestampTz GetCurrentTimestamp(void)
Definition: timestamp.c:1569
pqsigfunc pqsignal_no_restart(int signo, pqsigfunc func)
Definition: pqsignal.c:71
void on_proc_exit(pg_on_exit_callback function, Datum arg)
Definition: ipc.c:305
void AddToDataDirLockFile(int target_line, const char *str)
Definition: miscinit.c:1254
#define SIGCHLD
Definition: win32_port.h:173
int wal_level
Definition: xlog.c:103
char * pstrdup(const char *in)
Definition: mcxt.c:1161
#define pg_hton16(x)
Definition: pg_bswap.h:120
static void dummy_handler(SIGNAL_ARGS)
Definition: postmaster.c:5271
void ParseLongOption(const char *string, char **name, char **value)
Definition: guc.c:10278
static struct @144 value
bool set_plan_disabling_options(const char *arg, GucContext context, GucSource source)
Definition: postgres.c:3386
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
#define write_stderr(str)
Definition: parallel.c:182
#define S_IROTH
Definition: win32_port.h:293
static bool CreateOptsFile(int argc, char *argv[], char *fullprogname)
Definition: postmaster.c:5560
bool CheckDateTokenTables(void)
Definition: datetime.c:4438
const char * GetConfigOption(const char *name, bool missing_ok, bool restrict_privileged)
Definition: guc.c:7511
int errcode(int sqlerrcode)
Definition: elog.c:570
#define LOG_METAINFO_DATAFILE
Definition: syslogger.h:97
const char * get_stats_option_name(const char *arg)
Definition: postgres.c:3428
int SysLogger_Start(void)
Definition: syslogger.c:546
void set_debug_options(int debug_flag, GucContext context, GucSource source)
Definition: postgres.c:3357
void checkDataDir(void)
Definition: miscinit.c:99
#define SIGPIPE
Definition: win32_port.h:168
#define SIGUSR2
Definition: win32_port.h:176
#define LOG
Definition: elog.h:26
void InitProcessGlobals(void)
Definition: postmaster.c:2568
const char * progname
Definition: pg_standby.c:37
#define fprintf
Definition: port.h:196
void list_free_deep(List *list)
Definition: list.c:1387
char * Unix_socket_directories
Definition: postmaster.c:200
bool IsBinaryUpgrade
Definition: globals.c:110
int getopt(int nargc, char *const *nargv, const char *ostr)
Definition: getopt.c:71
#define PG_SETMASK(mask)
Definition: pqsignal.h:19
bool load_ident(void)
Definition: hba.c:2979
void autovac_init(void)
Definition: autovacuum.c:3258
void pqinitmask(void)
Definition: pqsignal.c:41
static void CloseServerPorts(int status, Datum arg)
Definition: postmaster.c:1392
static void InitPostmasterDeathWatchHandle(void)
Definition: postmaster.c:6473
bool SplitDirectoriesString(char *rawstring, char separator, List **namelist)
Definition: varlena.c:3796
#define PM_STATUS_STARTING
Definition: pidfile.h:50
void pfree(void *pointer)
Definition: mcxt.c:1031
int optind
Definition: getopt.c:50
#define S_IWUSR
Definition: win32_port.h:272
#define ERROR
Definition: elog.h:43
void CreateDataDirLockFile(bool amPostmaster)
Definition: miscinit.c:1177
static pid_t StartupPID
Definition: postmaster.c:250
int PostPortNumber
Definition: postmaster.c:197
static void checkControlFile(void)
Definition: postmaster.c:1493
int ReservedBackends
Definition: postmaster.c:214
static void ExitPostmaster(int status) pg_attribute_noreturn()
Definition: postmaster.c:5046
#define FATAL
Definition: elog.h:52
#define LOCK_FILE_LINE_SOCKET_DIR
Definition: pidfile.h:40
char * external_pid_file
Definition: guc.c:525
#define ALLOCSET_DEFAULT_SIZES
Definition: memutils.h:191
Definition: dest.h:88
void SetConfigOption(const char *name, const char *value, GucContext context, GucSource source)
Definition: guc.c:7487
bool load_hba(void)
Definition: hba.c:2183
char * bonjour_name
Definition: postmaster.c:246
bool SplitIdentifierString(char *rawstring, char separator, List **namelist)
Definition: varlena.c:3669
int XLogArchiveMode
Definition: xlog.c:91
int errcode_for_file_access(void)
Definition: elog.c:593
static pid_t SysLoggerPID
Definition: postmaster.c:258
#define SIGHUP
Definition: win32_port.h:163
void LocalProcessControlFile(bool reset)
Definition: xlog.c:4922
void ChangeToDataDir(void)
Definition: miscinit.c:213
int opterr
Definition: getopt.c:49
static void getInstallationPaths(const char *argv0)
Definition: postmaster.c:1440
char * Log_destination_string
Definition: elog.c:107
char * ListenAddresses
Definition: postmaster.c:203
int StreamServerPort(int family, char *hostName, unsigned short portNumber, char *unixSocketDir, pgsocket ListenSocket[], int MaxListen)
Definition: pqcomm.c:330
#define ereport(elevel, rest)
Definition: elog.h:141
#define STATUS_OK
Definition: c.h:1089
MemoryContext TopMemoryContext
Definition: mcxt.c:44
static void pmdie(SIGNAL_ARGS)
Definition: postmaster.c:2694
static void SIGHUP_handler(SIGNAL_ARGS)
Definition: postmaster.c:2620
#define LOCK_FILE_LINE_LISTEN_ADDR
Definition: pidfile.h:41
bool enable_bonjour
Definition: postmaster.c:245
void RemovePromoteSignalFiles(void)
Definition: xlog.c:12198
int max_wal_senders
Definition: walsender.c:120
#define SIG_IGN
Definition: win32_port.h:160
pid_t PostmasterPid
Definition: globals.c:95
#define WARNING
Definition: elog.h:40
char my_exec_path[MAXPGPATH]
Definition: globals.c:72
sigset_t BlockSig
Definition: pqsignal.c:22
static pgsocket ListenSocket[MAXLISTEN]
Definition: postmaster.c:218
static PMState pmState
Definition: postmaster.c:341
bool SelectConfigFiles(const char *userDoption, const char *progname)
Definition: guc.c:5339
void ApplyLauncherRegister(void)
Definition: launcher.c:789
#define PGINVALID_SOCKET
Definition: port.h:33
#define PG_MODE_MASK_OWNER
Definition: file_perm.h:24
int MaxConnections
Definition: globals.c:132
void RemoveLogrotateSignalFiles(void)
Definition: syslogger.c:1552
TimestampTz PgStartTime
Definition: timestamp.c:49
#define LOG_DESTINATION_STDERR
Definition: elog.h:412
static void reset_shared(int port)
Definition: postmaster.c:2602
static bool Reinit
Definition: postmaster.c:232
pqsigfunc pqsignal(int signum, pqsigfunc handler)
Definition: signal.c:170
#define free(a)
Definition: header.h:65
int errmsg_internal(const char *fmt,...)
Definition: elog.c:814
static char ExtraOptions[MAXPGPATH]
Definition: postmaster.c:223
static int ServerLoop(void)
Definition: postmaster.c:1620
#define Assert(condition)
Definition: c.h:732
#define lfirst(lc)
Definition: pg_list.h:190
void RemovePgTempFiles(void)
Definition: fd.c:2885
static void reaper(SIGNAL_ARGS)
Definition: postmaster.c:2873
void InitializeMaxBackends(void)
Definition: postinit.c:528
#define strerror
Definition: port.h:205
#define SIGALRM
Definition: win32_port.h:169
const char * name
Definition: encode.c:521
#define S_IRUSR
Definition: win32_port.h:269
static const char * userDoption
Definition: postgres.c:161
void set_max_safe_fds(void)
Definition: fd.c:903
int errmsg(const char *fmt,...)
Definition: elog.c:784
char * optarg
Definition: getopt.c:52
void list_free(List *list)
Definition: list.c:1373
#define elog(elevel,...)
Definition: elog.h:226
int i
static void sigusr1_handler(SIGNAL_ARGS)
Definition: postmaster.c:5079
void pgstat_init(void)
Definition: pgstat.c:356
int Log_destination
Definition: elog.c:106
char ** environ
CommandDest whereToSendOutput
Definition: postgres.c:90
static void static void status(const char *fmt,...) pg_attribute_printf(1
Definition: pg_regress.c:227
static bool success
Definition: initdb.c:163
static int SendStop
Definition: postmaster.c:233
void process_shared_preload_libraries(void)
Definition: miscinit.c:1583
#define LOCK_FILE_LINE_PM_STATUS
Definition: pidfile.h:43
Definition: pg_list.h:50
#define snprintf
Definition: port.h:192
#define MAXLISTEN
Definition: postmaster.c:217
MemoryContext PostmasterContext
Definition: mcxt.c:46
static void maybe_start_bgworkers(void)
Definition: postmaster.c:5884
void InitializeGUCOptions(void)
Definition: guc.c:5117

◆ PostmasterMarkPIDForWorkerNotify()

bool PostmasterMarkPIDForWorkerNotify ( int  )

Definition at line 6003 of file postmaster.c.

References AllocateFile(), Assert, AuxiliaryProcs, bkend::bgworker_notify, bkend::child_slot, closesocket, dlist_iter::cur, DataDir, generate_unaccent_rules::dest, dlist_container, dlist_foreach, bkend::elem, ereport, errmsg(), errmsg_internal(), ExtraOptions, first_syslogger_file_time, free, FreeFile(), i, IsBinaryUpgrade, sort-test::key, ListenSocket, LOG, MainLWLockArray, max_safe_fds, MaxBackends, MaxLivePostmasterChildren(), MAXPGPATH, mul_size(), my_exec_path, MyCancelKey, MyPMChildSlot, NamedLWLockTrancheArray, NamedLWLockTrancheRequests, PG_BINARY_R, pg_queue_signal(), PGINVALID_SOCKET, PgReloadTime, PgStartTime, pgStatSock, pgwin32_create_signal_listener(), pgwin32_initial_signal_pipe, bkend::pid, pkglib_path, PMSignalState, postmaster_alive_fds, PostmasterPid, PreparedXactProcs, ProcGlobal, ProcStructLock, redirection_done, SetDataDir(), ShmemAlloc(), ShmemLock, ShmemProtectiveRegion, ShmemVariableCache, SIGCHLD, Port::sock, SpinlockSemaArray, strerror, strlcpy(), syslogPipe, TRUE, UsedShmemSegAddr, UsedShmemSegID, and write_stderr.

Referenced by BackgroundWorkerStateChange().

6004 {
6005  dlist_iter iter;
6006  Backend *bp;
6007 
6008  dlist_foreach(iter, &BackendList)
6009  {
6010  bp = dlist_container(Backend, elem, iter.cur);
6011  if (bp->pid == pid)
6012  {
6013  bp->bgworker_notify = true;
6014  return true;
6015  }
6016  }
6017  return false;
6018 }
#define dlist_foreach(iter, lhead)
Definition: ilist.h:507
bool bgworker_notify
Definition: postmaster.c:182
#define dlist_container(type, membername, ptr)
Definition: ilist.h:477
static dlist_head BackendList
Definition: postmaster.c:186
dlist_node * cur
Definition: ilist.h:161
pid_t pid
Definition: postmaster.c:171

Variable Documentation

◆ AuthenticationTimeout

int AuthenticationTimeout

Definition at line 239 of file postmaster.c.

Referenced by BackendInitialize(), and PerformAuthentication().

◆ bonjour_name

char* bonjour_name

Definition at line 246 of file postmaster.c.

Referenced by PostmasterMain().

◆ ClientAuthInProgress

◆ enable_bonjour

bool enable_bonjour

Definition at line 245 of file postmaster.c.

Referenced by PostmasterMain().

◆ EnableSSL

bool EnableSSL

Definition at line 236 of file postmaster.c.

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

◆ ListenAddresses

char* ListenAddresses

Definition at line 203 of file postmaster.c.

Referenced by PostmasterMain().

◆ Log_connections

bool Log_connections

Definition at line 242 of file postmaster.c.

Referenced by BackendInitialize(), and PerformAuthentication().

◆ log_hostname

bool log_hostname

Definition at line 241 of file postmaster.c.

Referenced by BackendInitialize().

◆ postmaster_alive_fds

◆ PostPortNumber

PGDLLIMPORT int PostPortNumber

◆ PreAuthDelay

int PreAuthDelay

Definition at line 238 of file postmaster.c.

Referenced by BackendInitialize().

◆ progname

◆ ReservedBackends

int ReservedBackends

Definition at line 214 of file postmaster.c.

Referenced by InitPostgres(), and PostmasterMain().

◆ restart_after_crash

bool restart_after_crash

Definition at line 247 of file postmaster.c.

Referenced by PostmasterStateMachine().

◆ Unix_socket_directories

char* Unix_socket_directories

Definition at line 200 of file postmaster.c.

Referenced by PostmasterMain().

◆ Unix_socket_group

char* Unix_socket_group

Definition at line 122 of file pqcomm.c.

Referenced by StreamServerPort().

◆ Unix_socket_permissions

int Unix_socket_permissions

Definition at line 121 of file pqcomm.c.

Referenced by show_unix_socket_permissions(), and StreamServerPort().