aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/postmaster/postmaster.c117
-rw-r--r--src/backend/utils/misc/guc.c18
-rw-r--r--src/backend/utils/misc/postgresql.conf.sample6
-rw-r--r--src/bin/psql/tab-complete.c3
-rw-r--r--src/include/miscadmin.h5
5 files changed, 66 insertions, 83 deletions
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index 2e13838e70e..671e0644d7c 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -37,7 +37,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.375 2004/03/15 16:18:42 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.376 2004/03/23 01:23:48 tgl Exp $
*
* NOTES
*
@@ -149,7 +149,7 @@ static Backend *ShmemBackendArray;
/* The socket number we are listening for connections on */
int PostPortNumber;
char *UnixSocketDir;
-char *VirtualHost;
+char *ListenAddresses;
/*
* MaxBackends is the limit on the number of backends we can start.
@@ -202,7 +202,6 @@ static bool Reinit = true;
static int SendStop = false;
/* still more option variables */
-bool NetServer = false; /* listen on TCP/IP */
bool EnableSSL = false;
bool SilentMode = false; /* silent mode (-S) */
@@ -513,10 +512,10 @@ PostmasterMain(int argc, char *argv[])
SetConfigOption("fsync", "false", PGC_POSTMASTER, PGC_S_ARGV);
break;
case 'h':
- SetConfigOption("virtual_host", optarg, PGC_POSTMASTER, PGC_S_ARGV);
+ SetConfigOption("listen_addresses", optarg, PGC_POSTMASTER, PGC_S_ARGV);
break;
case 'i':
- SetConfigOption("tcpip_socket", "true", PGC_POSTMASTER, PGC_S_ARGV);
+ SetConfigOption("listen_addresses", "*", PGC_POSTMASTER, PGC_S_ARGV);
break;
case 'k':
SetConfigOption("unix_socket_directory", optarg, PGC_POSTMASTER, PGC_S_ARGV);
@@ -704,11 +703,6 @@ PostmasterMain(int argc, char *argv[])
* Initialize SSL library, if specified.
*/
#ifdef USE_SSL
- if (EnableSSL && !NetServer)
- {
- postmaster_error("TCP/IP connections must be enabled for SSL");
- ExitPostmaster(1);
- }
if (EnableSSL)
secure_initialize();
#endif
@@ -753,68 +747,60 @@ PostmasterMain(int argc, char *argv[])
for (i = 0; i < MAXLISTEN; i++)
ListenSocket[i] = -1;
- if (NetServer)
+ if (ListenAddresses)
{
- if (VirtualHost && VirtualHost[0])
- {
- char *curhost,
- *endptr;
- char c = 0;
+ char *curhost,
+ *endptr;
+ char c;
- curhost = VirtualHost;
- for (;;)
- {
- while (*curhost == ' ') /* skip any extra spaces */
- curhost++;
- if (*curhost == '\0')
- break;
- endptr = strchr(curhost, ' ');
- if (endptr)
- {
- c = *endptr;
- *endptr = '\0';
- }
+ curhost = ListenAddresses;
+ for (;;)
+ {
+ /* 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';
+ if (strcmp(curhost,"*") == 0)
+ status = StreamServerPort(AF_UNSPEC, NULL,
+ (unsigned short) PostPortNumber,
+ UnixSocketDir,
+ ListenSocket, MAXLISTEN);
+ else
status = StreamServerPort(AF_UNSPEC, curhost,
(unsigned short) PostPortNumber,
UnixSocketDir,
ListenSocket, MAXLISTEN);
- if (status != STATUS_OK)
- ereport(FATAL,
- (errmsg("could not create listen socket for \"%s\"",
- curhost)));
- if (endptr)
- {
- *endptr = c;
- curhost = endptr + 1;
- }
- else
- break;
- }
- }
- else
- {
- status = StreamServerPort(AF_UNSPEC, NULL,
- (unsigned short) PostPortNumber,
- UnixSocketDir,
- ListenSocket, MAXLISTEN);
if (status != STATUS_OK)
- ereport(FATAL,
- (errmsg("could not create TCP/IP listen socket")));
+ ereport(WARNING,
+ (errmsg("could not create listen socket for \"%s\"",
+ curhost)));
+ *endptr = c;
+ if (c != '\0')
+ curhost = endptr+1;
+ else
+ break;
}
+ }
#ifdef USE_RENDEZVOUS
- if (rendezvous_name != NULL)
- {
- DNSServiceRegistrationCreate(rendezvous_name,
- "_postgresql._tcp.",
- "",
- htonl(PostPortNumber),
- "",
- (DNSServiceRegistrationReply) reg_reply,
- NULL);
- }
-#endif
+ /* Register for Rendezvous only if we opened TCP socket(s) */
+ if (ListenSocket[0] != -1 && rendezvous_name != NULL)
+ {
+ DNSServiceRegistrationCreate(rendezvous_name,
+ "_postgresql._tcp.",
+ "",
+ htonl(PostPortNumber),
+ "",
+ (DNSServiceRegistrationReply) reg_reply,
+ NULL);
}
+#endif
#ifdef HAVE_UNIX_SOCKETS
status = StreamServerPort(AF_UNIX, NULL,
@@ -822,10 +808,17 @@ PostmasterMain(int argc, char *argv[])
UnixSocketDir,
ListenSocket, MAXLISTEN);
if (status != STATUS_OK)
- ereport(FATAL,
+ ereport(WARNING,
(errmsg("could not create Unix-domain socket")));
#endif
+ /*
+ * check that we have some socket to listen on
+ */
+ if (ListenSocket[0] == -1)
+ ereport(FATAL,
+ (errmsg("no socket configured to listen on")));
+
XLOGPathInit();
/*
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 5c0f0a96f1f..280977d60c1 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -10,7 +10,7 @@
* Written by Peter Eisentraut <peter_e@gmx.net>.
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.191 2004/03/22 03:15:29 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.192 2004/03/23 01:23:48 tgl Exp $
*
*--------------------------------------------------------------------
*/
@@ -444,14 +444,6 @@ static struct config_bool ConfigureNamesBool[] =
false, NULL, NULL
},
{
- {"tcpip_socket", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
- gettext_noop("Makes the server accept TCP/IP connections."),
- NULL
- },
- &NetServer,
- false, NULL, NULL
- },
- {
{"ssl", PGC_POSTMASTER, CONN_AUTH_SECURITY,
gettext_noop("Enables SSL connections."),
NULL
@@ -1711,12 +1703,12 @@ static struct config_string ConfigureNamesString[] =
},
{
- {"virtual_host", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
- gettext_noop("Sets the host name or IP address to listen to."),
+ {"listen_addresses", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
+ gettext_noop("Sets the host name or IP addresses to listen to."),
NULL
},
- &VirtualHost,
- "", NULL, NULL
+ &ListenAddresses,
+ "localhost", NULL, NULL
},
{
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index 91b0340963c..3bec1e9a757 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -27,17 +27,17 @@
# - Connection Settings -
-#tcpip_socket = false
+#listen_addresses = 'localhost' # what IP interface(s) to listen on;
+ # defaults to localhost, '*' = any
+#port = 5432
#max_connections = 100
# note: increasing max_connections costs about 500 bytes of shared
# memory per connection slot, in addition to costs from shared_buffers
# and max_locks_per_transaction.
#superuser_reserved_connections = 2
-#port = 5432
#unix_socket_directory = ''
#unix_socket_group = ''
#unix_socket_permissions = 0777 # octal
-#virtual_host = '' # what interface to listen on; defaults to any
#rendezvous_name = '' # defaults to the computer name
# - Security & Authentication -
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index bea56852e43..8b607158219 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.101 2004/02/03 17:34:03 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.102 2004/03/23 01:23:48 tgl Exp $
*/
/*----------------------------------------------------------------------
@@ -560,7 +560,6 @@ psql_completion(char *text, int start, int end)
"syslog",
"syslog_facility",
"syslog_ident",
- "tcpip_socket",
"TimeZone",
"trace_notify",
"transform_null_equals",
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index b43d481c52a..f34ebb09865 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/miscadmin.h,v 1.153 2004/02/10 03:42:45 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/miscadmin.h,v 1.154 2004/03/23 01:23:48 tgl Exp $
*
* NOTES
* some of the information in this file should be moved to
@@ -212,7 +212,6 @@ extern bool VacuumCostActive;
* A few postmaster startup options are exported here so the
* configuration file processor can access them.
*/
-extern bool NetServer;
extern bool EnableSSL;
extern bool SilentMode;
extern int MaxBackends;
@@ -222,7 +221,7 @@ extern int PostPortNumber;
extern int Unix_socket_permissions;
extern char *Unix_socket_group;
extern char *UnixSocketDir;
-extern char *VirtualHost;
+extern char *ListenAddresses;
/*****************************************************************************