Make listen_addresses be a comma-separated list instead of a space-separated
authorTom Lane
Sun, 8 Aug 2004 20:17:36 +0000 (20:17 +0000)
committerTom Lane
Sun, 8 Aug 2004 20:17:36 +0000 (20:17 +0000)
list.  More consistent with our other list-containing GUC variables.

doc/src/sgml/runtime.sgml
src/backend/postmaster/postmaster.c
src/backend/utils/misc/guc.c

index d393a6d1803276cbcaeab8c95a7dafe280e1a660..117a0eb21b38198110044c7841a1b39a1b21f571 100644 (file)
@@ -1,5 +1,5 @@
 
 
 
@@ -626,7 +626,7 @@ SET ENABLE_SEQSCAN TO OFF;
        
          Specifies the TCP/IP address(es) on which the server is
          to listen for connections from client applications.  
-         The value takes the form of a space-separated list of host names
+         The value takes the form of a comma-separated list of host names
          and/or numeric IP addresses.  The special entry *
          corresponds to all available IP interfaces.
          If the list is empty, the server does not listen on any IP interface
index 870ad318a830bb26349f6c7cb9bff8369d0cc87f..f4ee0c8937cfd6f2eb109001e9ab5fe470441afe 100644 (file)
@@ -37,7 +37,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.420 2004/08/05 23:32:10 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.421 2004/08/08 20:17:34 tgl Exp $
  *
  * NOTES
  *
 #include "storage/bufmgr.h"
 #include "access/xlog.h"
 #include "tcop/tcopprot.h"
+#include "utils/builtins.h"
 #include "utils/guc.h"
 #include "utils/memutils.h"
 #include "utils/ps_status.h"
@@ -698,23 +699,26 @@ PostmasterMain(int argc, char *argv[])
 
    if (ListenAddresses)
    {
-       char       *curhost,
-                  *endptr;
-       char        c;
+       char *rawstring;
+       List *elemlist;
+       ListCell *l;
 
-       curhost = ListenAddresses;
-       for (;;)
+       /* Need a modifiable copy of ListenAddresses */
+       rawstring = pstrdup(ListenAddresses);
+
+       /* Parse string into list of identifiers */
+       if (!SplitIdentifierString(rawstring, ',', &elemlist)) 
        {
-           /* ignore whitespace */
-           while (isspace((unsigned char) *curhost))
-               curhost++;
-           if (*curhost == '\0')
-               break;
-           endptr = curhost;
-           while (*endptr != '\0' && !isspace((unsigned char) *endptr))
-               endptr++;
-           c = *endptr;
-           *endptr = '\0';
+           /* syntax error in list */
+           ereport(FATAL,
+                   (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+                    errmsg("invalid list syntax for \"listen_addresses\"")));
+       }
+
+       foreach(l, elemlist)
+       {
+           char *curhost = (char *) lfirst(l);
+
            if (strcmp(curhost, "*") == 0)
                status = StreamServerPort(AF_UNSPEC, NULL,
                                          (unsigned short) PostPortNumber,
@@ -729,12 +733,10 @@ PostmasterMain(int argc, char *argv[])
                ereport(WARNING,
                     (errmsg("could not create listen socket for \"%s\"",
                             curhost)));
-           *endptr = c;
-           if (c != '\0')
-               curhost = endptr + 1;
-           else
-               break;
        }
+
+       list_free(elemlist);
+       pfree(rawstring);
    }
 
 #ifdef USE_RENDEZVOUS
index d619501850ee810349baf35f608bdd2416ee86b3..5c4908f27daced140687f95e4e3079db5ae8e456 100644 (file)
@@ -10,7 +10,7 @@
  * Written by Peter Eisentraut .
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.229 2004/08/08 15:37:06 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.230 2004/08/08 20:17:36 tgl Exp $
  *
  *--------------------------------------------------------------------
  */
@@ -1740,8 +1740,9 @@ static struct config_string ConfigureNamesString[] =
 
    {
        {"listen_addresses", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
-           gettext_noop("Sets the host name or IP addresses to listen to."),
-           NULL
+           gettext_noop("Sets the host name or IP address(es) to listen to."),
+           NULL,
+           GUC_LIST_INPUT
        },
        &ListenAddresses,
        "localhost", NULL, NULL