Make listen_addresses be a comma-separated list instead of a space-separated

list.  More consistent with our other list-containing GUC variables.
This commit is contained in:
Tom Lane 2004-08-08 20:17:36 +00:00
parent dc199eafa7
commit 33bf242a8a
3 changed files with 29 additions and 26 deletions

View File

@ -1,5 +1,5 @@
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.274 2004/08/08 19:42:56 tgl Exp $ $PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.275 2004/08/08 20:17:33 tgl Exp $
--> -->
<Chapter Id="runtime"> <Chapter Id="runtime">
@ -626,7 +626,7 @@ SET ENABLE_SEQSCAN TO OFF;
<para> <para>
Specifies the TCP/IP address(es) on which the server is Specifies the TCP/IP address(es) on which the server is
to listen for connections from client applications. 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 <literal>*</> and/or numeric IP addresses. The special entry <literal>*</>
corresponds to all available IP interfaces. corresponds to all available IP interfaces.
If the list is empty, the server does not listen on any IP interface If the list is empty, the server does not listen on any IP interface

View File

@ -37,7 +37,7 @@
* *
* *
* IDENTIFICATION * 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 * NOTES
* *
@ -113,6 +113,7 @@
#include "storage/bufmgr.h" #include "storage/bufmgr.h"
#include "access/xlog.h" #include "access/xlog.h"
#include "tcop/tcopprot.h" #include "tcop/tcopprot.h"
#include "utils/builtins.h"
#include "utils/guc.h" #include "utils/guc.h"
#include "utils/memutils.h" #include "utils/memutils.h"
#include "utils/ps_status.h" #include "utils/ps_status.h"
@ -698,23 +699,26 @@ PostmasterMain(int argc, char *argv[])
if (ListenAddresses) if (ListenAddresses)
{ {
char *curhost, char *rawstring;
*endptr; List *elemlist;
char c; ListCell *l;
curhost = ListenAddresses; /* Need a modifiable copy of ListenAddresses */
for (;;) rawstring = pstrdup(ListenAddresses);
/* Parse string into list of identifiers */
if (!SplitIdentifierString(rawstring, ',', &elemlist))
{ {
/* ignore whitespace */ /* syntax error in list */
while (isspace((unsigned char) *curhost)) ereport(FATAL,
curhost++; (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
if (*curhost == '\0') errmsg("invalid list syntax for \"listen_addresses\"")));
break; }
endptr = curhost;
while (*endptr != '\0' && !isspace((unsigned char) *endptr)) foreach(l, elemlist)
endptr++; {
c = *endptr; char *curhost = (char *) lfirst(l);
*endptr = '\0';
if (strcmp(curhost, "*") == 0) if (strcmp(curhost, "*") == 0)
status = StreamServerPort(AF_UNSPEC, NULL, status = StreamServerPort(AF_UNSPEC, NULL,
(unsigned short) PostPortNumber, (unsigned short) PostPortNumber,
@ -729,12 +733,10 @@ PostmasterMain(int argc, char *argv[])
ereport(WARNING, ereport(WARNING,
(errmsg("could not create listen socket for \"%s\"", (errmsg("could not create listen socket for \"%s\"",
curhost))); curhost)));
*endptr = c;
if (c != '\0')
curhost = endptr + 1;
else
break;
} }
list_free(elemlist);
pfree(rawstring);
} }
#ifdef USE_RENDEZVOUS #ifdef USE_RENDEZVOUS

View File

@ -10,7 +10,7 @@
* Written by Peter Eisentraut <peter_e@gmx.net>. * Written by Peter Eisentraut <peter_e@gmx.net>.
* *
* IDENTIFICATION * 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, {"listen_addresses", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
gettext_noop("Sets the host name or IP addresses to listen to."), gettext_noop("Sets the host name or IP address(es) to listen to."),
NULL NULL,
GUC_LIST_INPUT
}, },
&ListenAddresses, &ListenAddresses,
"localhost", NULL, NULL "localhost", NULL, NULL