]> granicus.if.org Git - postgresql/blobdiff - src/backend/postmaster/postmaster.c
Replace the BufMgrLock with separate locks on the lookup hashtable and
[postgresql] / src / backend / postmaster / postmaster.c
index 6a7cc060963b9e811549df749d0d546bc744626e..d84bf2775768ee2628cbc09ee84bfbff89959964 100644 (file)
@@ -37,7 +37,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.442 2004/12/31 22:00:40 pgsql Exp $
+ *       $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.445 2005/02/22 04:36:36 momjian Exp $
  *
  * NOTES
  *
@@ -92,6 +92,7 @@
 #include <DNSServiceDiscovery/DNSServiceDiscovery.h>
 #endif
 
+#include "catalog/pg_control.h"
 #include "catalog/pg_database.h"
 #include "commands/async.h"
 #include "lib/dllist.h"
@@ -167,7 +168,7 @@ int                 ReservedBackends;
 static const char *progname = NULL;
 
 /* The socket(s) we're listening to. */
-#define MAXLISTEN      10
+#define MAXLISTEN      64
 static int     ListenSocket[MAXLISTEN];
 
 /*
@@ -337,8 +338,8 @@ typedef struct
 #endif
        char my_exec_path[MAXPGPATH];
        char ExtraOptions[MAXPGPATH];
-       char lc_collate[MAXPGPATH];
-       char lc_ctype[MAXPGPATH];
+       char lc_collate[LOCALE_NAME_BUFLEN];
+       char lc_ctype[LOCALE_NAME_BUFLEN];
 } BackendParameters;
 
 static void read_backend_variables(char *id, Port *port);
@@ -902,12 +903,10 @@ PostmasterMain(int argc, char *argv[])
        pgstat_init();
 
        /*
-        * Load cached files for client authentication.
+        * Load configuration files for client authentication.
         */
        load_hba();
        load_ident();
-       load_user();
-       load_group();
 
        /*
         * We're ready to rock and roll...
@@ -1066,35 +1065,35 @@ pmdaemonize(void)
 static void
 usage(const char *progname)
 {
-       printf(gettext("%s is the PostgreSQL server.\n\n"), progname);
-       printf(gettext("Usage:\n  %s [OPTION]...\n\n"), progname);
-       printf(gettext("Options:\n"));
+       printf(_("%s is the PostgreSQL server.\n\n"), progname);
+       printf(_("Usage:\n  %s [OPTION]...\n\n"), progname);
+       printf(_("Options:\n"));
 #ifdef USE_ASSERT_CHECKING
-       printf(gettext("  -A 1|0          enable/disable run-time assert checking\n"));
+       printf(_("  -A 1|0          enable/disable run-time assert checking\n"));
 #endif
-       printf(gettext("  -B NBUFFERS     number of shared buffers\n"));
-       printf(gettext("  -c NAME=VALUE   set run-time parameter\n"));
-       printf(gettext("  -d 1-5          debugging level\n"));
-       printf(gettext("  -D DATADIR      database directory\n"));
-       printf(gettext("  -F              turn fsync off\n"));
-       printf(gettext("  -h HOSTNAME     host name or IP address to listen on\n"));
-       printf(gettext("  -i              enable TCP/IP connections\n"));
-       printf(gettext("  -k DIRECTORY    Unix-domain socket location\n"));
+       printf(_("  -B NBUFFERS     number of shared buffers\n"));
+       printf(_("  -c NAME=VALUE   set run-time parameter\n"));
+       printf(_("  -d 1-5          debugging level\n"));
+       printf(_("  -D DATADIR      database directory\n"));
+       printf(_("  -F              turn fsync off\n"));
+       printf(_("  -h HOSTNAME     host name or IP address to listen on\n"));
+       printf(_("  -i              enable TCP/IP connections\n"));
+       printf(_("  -k DIRECTORY    Unix-domain socket location\n"));
 #ifdef USE_SSL
-       printf(gettext("  -l              enable SSL connections\n"));
+       printf(_("  -l              enable SSL connections\n"));
 #endif
-       printf(gettext("  -N MAX-CONNECT  maximum number of allowed connections\n"));
-       printf(gettext("  -o OPTIONS      pass \"OPTIONS\" to each server process\n"));
-       printf(gettext("  -p PORT         port number to listen on\n"));
-       printf(gettext("  -S              silent mode (start in background without logging output)\n"));
-       printf(gettext("  --help          show this help, then exit\n"));
-       printf(gettext("  --version       output version information, then exit\n"));
-
-       printf(gettext("\nDeveloper options:\n"));
-       printf(gettext("  -n              do not reinitialize shared memory after abnormal exit\n"));
-       printf(gettext("  -s              send SIGSTOP to all backend servers if one dies\n"));
-
-       printf(gettext("\nPlease read the documentation for the complete list of run-time\n"
+       printf(_("  -N MAX-CONNECT  maximum number of allowed connections\n"));
+       printf(_("  -o OPTIONS      pass \"OPTIONS\" to each server process\n"));
+       printf(_("  -p PORT         port number to listen on\n"));
+       printf(_("  -S              silent mode (start in background without logging output)\n"));
+       printf(_("  --help          show this help, then exit\n"));
+       printf(_("  --version       output version information, then exit\n"));
+
+       printf(_("\nDeveloper options:\n"));
+       printf(_("  -n              do not reinitialize shared memory after abnormal exit\n"));
+       printf(_("  -s              send SIGSTOP to all backend servers if one dies\n"));
+
+       printf(_("\nPlease read the documentation for the complete list of run-time\n"
                                   "configuration settings and how to set them on the command line or in\n"
                                   "the configuration file.\n\n"
                                   "Report bugs to <pgsql-bugs@postgresql.org>.\n"));
@@ -1796,6 +1795,8 @@ SIGHUP_handler(SIGNAL_ARGS)
                if (SysLoggerPID != 0)
                        kill(SysLoggerPID, SIGHUP);
                /* PgStatPID does not currently need SIGHUP */
+
+               /* Reload authentication config files too */
                load_hba();
                load_ident();
 
@@ -1992,7 +1993,7 @@ reaper(SIGNAL_ARGS)
                        StartupPID = 0;
                        if (exitstatus != 0)
                        {
-                               LogChildExit(LOG, gettext("startup process"),
+                               LogChildExit(LOG, _("startup process"),
                                                         pid, exitstatus);
                                ereport(LOG,
                                                (errmsg("aborting startup due to startup process failure")));
@@ -2005,6 +2006,14 @@ reaper(SIGNAL_ARGS)
                         */
                        FatalError = false;
 
+                       /*
+                        * Load the flat user/group files into postmaster's caches.
+                        * The startup process has recomputed these from the database
+                        * contents, so we wait till it finishes before loading them.
+                        */
+                       load_user();
+                       load_group();
+
                        /*
                         * Crank up the background writer.      It doesn't matter if this
                         * fails, we'll just try again later.
@@ -2058,7 +2067,7 @@ reaper(SIGNAL_ARGS)
                         * Any unexpected exit of the bgwriter is treated as a crash.
                         */
                        HandleChildCrash(pid, exitstatus,
-                                                        gettext("background writer process"));
+                                                        _("background writer process"));
                        continue;
                }
 
@@ -2071,7 +2080,7 @@ reaper(SIGNAL_ARGS)
                {
                        PgArchPID = 0;
                        if (exitstatus != 0)
-                               LogChildExit(LOG, gettext("archiver process"),
+                               LogChildExit(LOG, _("archiver process"),
                                                         pid, exitstatus);
                        if (XLogArchivingActive() &&
                                StartupPID == 0 && !FatalError && Shutdown == NoShutdown)
@@ -2088,7 +2097,7 @@ reaper(SIGNAL_ARGS)
                {
                        PgStatPID = 0;
                        if (exitstatus != 0)
-                               LogChildExit(LOG, gettext("statistics collector process"),
+                               LogChildExit(LOG, _("statistics collector process"),
                                                         pid, exitstatus);
                        if (StartupPID == 0 && !FatalError && Shutdown == NoShutdown)
                                PgStatPID = pgstat_start();
@@ -2102,7 +2111,7 @@ reaper(SIGNAL_ARGS)
                        /* for safety's sake, launch new logger *first* */
                        SysLoggerPID = SysLogger_Start();
                        if (exitstatus != 0)
-                               LogChildExit(LOG, gettext("system logger process"),
+                               LogChildExit(LOG, _("system logger process"),
                                                         pid, exitstatus);
                        continue;
                }
@@ -2169,7 +2178,7 @@ CleanupBackend(int pid,
 {
        Dlelem     *curr;
 
-       LogChildExit(DEBUG2, gettext("server process"), pid, exitstatus);
+       LogChildExit(DEBUG2, _("server process"), pid, exitstatus);
 
        /*
         * If a backend dies in an ugly way (i.e. exit status not 0) then we
@@ -2179,7 +2188,7 @@ CleanupBackend(int pid,
         */
        if (exitstatus != 0)
        {
-               HandleChildCrash(pid, exitstatus, gettext("server process"));
+               HandleChildCrash(pid, exitstatus, _("server process"));
                return;
        }
 
@@ -2503,7 +2512,7 @@ report_fork_failure_to_client(Port *port, int errnum)
 
        /* Format the error message packet (always V2 protocol) */
        snprintf(buffer, sizeof(buffer), "E%s%s\n",
-                        gettext("could not fork new process for connection: "),
+                        _("could not fork new process for connection: "),
                         strerror(errnum));
 
        /* Set port to non-blocking.  Don't do send() if this fails */
@@ -2661,7 +2670,7 @@ BackendRun(Port *port)
        port->remote_port = strdup(remote_port);
 
        /*
-        * In EXEC_BACKEND case, we didn't inherit the contents of pg_hba.c
+        * In EXEC_BACKEND case, we didn't inherit the contents of pg_hba.conf
         * etcetera from the postmaster, and have to load them ourselves.
         * Build the PostmasterContext (which didn't exist before, in this
         * process) to contain the data.
@@ -3682,8 +3691,8 @@ save_backend_variables(BackendParameters *param, Port *port,
 
        StrNCpy(param->ExtraOptions, ExtraOptions, MAXPGPATH);
 
-       StrNCpy(param->lc_collate, setlocale(LC_COLLATE, NULL), MAXPGPATH);
-       StrNCpy(param->lc_ctype, setlocale(LC_CTYPE, NULL), MAXPGPATH);
+       StrNCpy(param->lc_collate, setlocale(LC_COLLATE, NULL), LOCALE_NAME_BUFLEN);
+       StrNCpy(param->lc_ctype, setlocale(LC_CTYPE, NULL), LOCALE_NAME_BUFLEN);
 
        return true;
 }