Skip to content

Commit 33bf242

Browse files
committed
Make listen_addresses be a comma-separated list instead of a space-separated
list. More consistent with our other list-containing GUC variables.
1 parent dc199ea commit 33bf242

File tree

3 files changed

+29
-26
lines changed

3 files changed

+29
-26
lines changed

doc/src/sgml/runtime.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.274 2004/08/08 19:42:56 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.275 2004/08/08 20:17:33 tgl Exp $
33
-->
44

55
<Chapter Id="runtime">
@@ -626,7 +626,7 @@ SET ENABLE_SEQSCAN TO OFF;
626626
<para>
627627
Specifies the TCP/IP address(es) on which the server is
628628
to listen for connections from client applications.
629-
The value takes the form of a space-separated list of host names
629+
The value takes the form of a comma-separated list of host names
630630
and/or numeric IP addresses. The special entry <literal>*</>
631631
corresponds to all available IP interfaces.
632632
If the list is empty, the server does not listen on any IP interface

src/backend/postmaster/postmaster.c

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.420 2004/08/05 23:32:10 tgl Exp $
40+
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.421 2004/08/08 20:17:34 tgl Exp $
4141
*
4242
* NOTES
4343
*
@@ -113,6 +113,7 @@
113113
#include "storage/bufmgr.h"
114114
#include "access/xlog.h"
115115
#include "tcop/tcopprot.h"
116+
#include "utils/builtins.h"
116117
#include "utils/guc.h"
117118
#include "utils/memutils.h"
118119
#include "utils/ps_status.h"
@@ -698,23 +699,26 @@ PostmasterMain(int argc, char *argv[])
698699

699700
if (ListenAddresses)
700701
{
701-
char *curhost,
702-
*endptr;
703-
char c;
702+
char *rawstring;
703+
List *elemlist;
704+
ListCell *l;
704705

705-
curhost = ListenAddresses;
706-
for (;;)
706+
/* Need a modifiable copy of ListenAddresses */
707+
rawstring = pstrdup(ListenAddresses);
708+
709+
/* Parse string into list of identifiers */
710+
if (!SplitIdentifierString(rawstring, ',', &elemlist))
707711
{
708-
/* ignore whitespace */
709-
while (isspace((unsigned char) *curhost))
710-
curhost++;
711-
if (*curhost == '\0')
712-
break;
713-
endptr = curhost;
714-
while (*endptr != '\0' && !isspace((unsigned char) *endptr))
715-
endptr++;
716-
c = *endptr;
717-
*endptr = '\0';
712+
/* syntax error in list */
713+
ereport(FATAL,
714+
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
715+
errmsg("invalid list syntax for \"listen_addresses\"")));
716+
}
717+
718+
foreach(l, elemlist)
719+
{
720+
char *curhost = (char *) lfirst(l);
721+
718722
if (strcmp(curhost, "*") == 0)
719723
status = StreamServerPort(AF_UNSPEC, NULL,
720724
(unsigned short) PostPortNumber,
@@ -729,12 +733,10 @@ PostmasterMain(int argc, char *argv[])
729733
ereport(WARNING,
730734
(errmsg("could not create listen socket for \"%s\"",
731735
curhost)));
732-
*endptr = c;
733-
if (c != '\0')
734-
curhost = endptr + 1;
735-
else
736-
break;
737736
}
737+
738+
list_free(elemlist);
739+
pfree(rawstring);
738740
}
739741

740742
#ifdef USE_RENDEZVOUS

src/backend/utils/misc/guc.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Written by Peter Eisentraut <peter_e@gmx.net>.
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.229 2004/08/08 15:37:06 momjian Exp $
13+
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.230 2004/08/08 20:17:36 tgl Exp $
1414
*
1515
*--------------------------------------------------------------------
1616
*/
@@ -1740,8 +1740,9 @@ static struct config_string ConfigureNamesString[] =
17401740

17411741
{
17421742
{"listen_addresses", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
1743-
gettext_noop("Sets the host name or IP addresses to listen to."),
1744-
NULL
1743+
gettext_noop("Sets the host name or IP address(es) to listen to."),
1744+
NULL,
1745+
GUC_LIST_INPUT
17451746
},
17461747
&ListenAddresses,
17471748
"localhost", NULL, NULL

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy