listening addresses

Поиск
Список
Период
Сортировка
Искать

listening addresses

От:
Andrew Dunstan <andrew@dunslane.net>
Дата:

I think this (undocumented!) patch implements what Tom and I thrashed 
out under this heading on -hackers.

It would make the default configuration listen on localhost, and allow 
'*' as a listen address to be every available listen interface. -i would 
correspond to this latter setting. It also will not now error out unless 
there is absolutely no socket, Unix or TCP, to listen on. To turn off 
all TCP sockets you would use -h '' or listen_addresses = ''.

Submitted for review.

cheers

andrew
Index: src/backend/postmaster/postmaster.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/backend/postmaster/postmaster.c,v
retrieving revision 1.375
diff -c -r1.375 postmaster.c
*** src/backend/postmaster/postmaster.c	15 Mar 2004 16:18:42 -0000	1.375
--- src/backend/postmaster/postmaster.c	21 Mar 2004 16:48:05 -0000
***************
*** 149,155 ****
  /* The socket number we are listening for connections on */
  int			PostPortNumber;
  char	   *UnixSocketDir;
! char	   *VirtualHost;
  
  /*
   * MaxBackends is the limit on the number of backends we can start.
--- 149,155 ----
  /* The socket number we are listening for connections on */
  int			PostPortNumber;
  char	   *UnixSocketDir;
! char	   *ListenAddresses = "localhost";
  
  /*
   * MaxBackends is the limit on the number of backends we can start.
***************
*** 202,208 ****
  static int	SendStop = false;
  
  /* still more option variables */
- bool		NetServer = false;	/* listen on TCP/IP */
  bool		EnableSSL = false;
  bool		SilentMode = false; /* silent mode (-S) */
  
--- 202,207 ----
***************
*** 412,417 ****
--- 411,417 ----
  	char		original_extraoptions[MAXPGPATH];
  	char	   *potential_DataDir = NULL;
  	int			i;
+ 	bool        NetServer = false;
  
  	*original_extraoptions = '\0';
  
***************
*** 513,522 ****
  				SetConfigOption("fsync", "false", PGC_POSTMASTER, PGC_S_ARGV);
  				break;
  			case 'h':
! 				SetConfigOption("virtual_host", optarg, PGC_POSTMASTER, PGC_S_ARGV);
  				break;
  			case 'i':
! 				SetConfigOption("tcpip_socket", "true", PGC_POSTMASTER, PGC_S_ARGV);
  				break;
  			case 'k':
  				SetConfigOption("unix_socket_directory", optarg, PGC_POSTMASTER, PGC_S_ARGV);
--- 513,522 ----
  				SetConfigOption("fsync", "false", PGC_POSTMASTER, PGC_S_ARGV);
  				break;
  			case 'h':
! 				SetConfigOption("listen_addresses", optarg, PGC_POSTMASTER, PGC_S_ARGV);
  				break;
  			case 'i':
! 				SetConfigOption("listen_addresses", "*", PGC_POSTMASTER, PGC_S_ARGV);
  				break;
  			case 'k':
  				SetConfigOption("unix_socket_directory", optarg, PGC_POSTMASTER, PGC_S_ARGV);
***************
*** 700,705 ****
--- 700,717 ----
  				(errmsg("%s: could not locate postgres executable",
  						progname)));
  
+ 	/* 
+ 	 * check if ListenAddresses is empty or all spaces
+ 	 */
+ 	for (i=strlen(ListenAddresses)-1; i >= 0; i--)
+ 	{
+ 		if (ListenAddresses[i] != ' ')
+ 		{
+ 			NetServer = true;
+ 			break;
+ 		}
+ 	}
+ 
  	/*
  	 * Initialize SSL library, if specified.
  	 */
***************
*** 755,767 ****
  
  	if (NetServer)
  	{
! 		if (VirtualHost && VirtualHost[0])
  		{
  			char	   *curhost,
  					   *endptr;
  			char		c = 0;
  
! 			curhost = VirtualHost;
  			for (;;)
  			{
  				while (*curhost == ' ') /* skip any extra spaces */
--- 767,779 ----
  
  	if (NetServer)
  	{
! 		if (strcmp(ListenAddresses,"*") != 0)
  		{
  			char	   *curhost,
  					   *endptr;
  			char		c = 0;
  
! 			curhost = ListenAddresses;
  			for (;;)
  			{
  				while (*curhost == ' ') /* skip any extra spaces */
***************
*** 779,785 ****
  										  UnixSocketDir,
  										  ListenSocket, MAXLISTEN);
  				if (status != STATUS_OK)
! 					ereport(FATAL,
  					 (errmsg("could not create listen socket for \"%s\"",
  							 curhost)));
  				if (endptr)
--- 791,797 ----
  										  UnixSocketDir,
  										  ListenSocket, MAXLISTEN);
  				if (status != STATUS_OK)
! 					ereport(WARNING,
  					 (errmsg("could not create listen socket for \"%s\"",
  							 curhost)));
  				if (endptr)
***************
*** 798,804 ****
  									  UnixSocketDir,
  									  ListenSocket, MAXLISTEN);
  			if (status != STATUS_OK)
! 				ereport(FATAL,
  					  (errmsg("could not create TCP/IP listen socket")));
  		}
  
--- 810,816 ----
  									  UnixSocketDir,
  									  ListenSocket, MAXLISTEN);
  			if (status != STATUS_OK)
! 				ereport(WARNING,
  					  (errmsg("could not create TCP/IP listen socket")));
  		}
  
***************
*** 822,830 ****
  							  UnixSocketDir,
  							  ListenSocket, MAXLISTEN);
  	if (status != STATUS_OK)
! 		ereport(FATAL,
  				(errmsg("could not create Unix-domain socket")));
  #endif
  
  	XLOGPathInit();
  
--- 834,850 ----
  							  UnixSocketDir,
  							  ListenSocket, MAXLISTEN);
  	if (status != STATUS_OK)
! 		ereport(WARNING,
  				(errmsg("could not create Unix-domain socket")));
  #endif
+ 
+     /*
+ 	 * check that we have some socket to talk on 
+ 	 */
+ 
+ 	if (ListenSocket[0] == -1)
+ 		ereport(FATAL,
+ 				(errmsg("not listening on any socket")));
  
  	XLOGPathInit();
  
Index: src/backend/utils/misc/guc.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/backend/utils/misc/guc.c,v
retrieving revision 1.190
diff -c -r1.190 guc.c
*** src/backend/utils/misc/guc.c	15 Mar 2004 15:56:24 -0000	1.190
--- src/backend/utils/misc/guc.c	21 Mar 2004 16:48:06 -0000
***************
*** 444,457 ****
  		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
--- 444,449 ----
***************
*** 1711,1722 ****
  	},
  
  	{
! 		{"virtual_host", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
! 			gettext_noop("Sets the host name or IP address to listen to."),
  			NULL
  		},
! 		&VirtualHost,
! 		"", NULL, NULL
  	},
  
  	{
--- 1703,1714 ----
  	},
  
  	{
! 		{"listen_addresses", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
! 			gettext_noop("Sets the host name or IP addresses to listen to."),
  			NULL
  		},
! 		&ListenAddresses,
! 		"localhost", NULL, NULL
  	},
  
  	{
Index: src/backend/utils/misc/postgresql.conf.sample
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/backend/utils/misc/postgresql.conf.sample,v
retrieving revision 1.108
diff -c -r1.108 postgresql.conf.sample
*** src/backend/utils/misc/postgresql.conf.sample	15 Mar 2004 15:56:26 -0000	1.108
--- src/backend/utils/misc/postgresql.conf.sample	21 Mar 2004 16:48:06 -0000
***************
*** 27,33 ****
  
  # - Connection Settings -
  
- #tcpip_socket = false
  #max_connections = 100
  	# note: increasing max_connections costs about 500 bytes of shared
  	# memory per connection slot, in addition to costs from shared_buffers
--- 27,32 ----
***************
*** 37,43 ****
  #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 -
--- 36,43 ----
  #unix_socket_directory = ''
  #unix_socket_group = ''
  #unix_socket_permissions = 0777	# octal
! #listen_addresses = 'localhost'	# what interface to listen on; 
! 				# defaults to localhost, '*' = any
  #rendezvous_name = ''		# defaults to the computer name
  
  # - Security & Authentication -
Index: src/include/miscadmin.h
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/include/miscadmin.h,v
retrieving revision 1.153
diff -c -r1.153 miscadmin.h
*** src/include/miscadmin.h	10 Feb 2004 03:42:45 -0000	1.153
--- src/include/miscadmin.h	21 Mar 2004 16:48:06 -0000
***************
*** 212,218 ****
   *	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;
--- 212,217 ----
***************
*** 222,228 ****
  extern int	Unix_socket_permissions;
  extern char *Unix_socket_group;
  extern char *UnixSocketDir;
! extern char *VirtualHost;
  
  
  /*****************************************************************************
--- 221,227 ----
  extern int	Unix_socket_permissions;
  extern char *Unix_socket_group;
  extern char *UnixSocketDir;
! extern char *ListenAddresses;
  
  
  /*****************************************************************************

Re: listening addresses

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Andrew Dunstan  writes:
> Submitted for review.

Okay, some random comments:

> ! char	   *ListenAddresses = "localhost";

I think you made this mistake in the log_line_prefix patch too.  The
contents of a GUC string var should always be either NULL or a pointer
to a malloc'd string --- ergo, its initial state must be NULL.  It's
pure luck that GUC doesn't dump core trying to free() this pointer.

> + 	/* 
> + 	 * check if ListenAddresses is empty or all spaces
> + 	 */

Why do you need this test (or the NetServer bool) at all?  Just scan
the string and bind to whatever it mentions.

BTW it'd be better to use isspace() instead of a hardwired test for ' '.

> ! 		if (strcmp(ListenAddresses,"*") != 0)

This seems a bit nonrobust since it will fail if any whitespace is
added.  I think it'd be better to test whether any individual hostname
extracted from the string is '*'.

> + 	if (ListenSocket[0] == -1)
> + 		ereport(FATAL,
> + 				(errmsg("not listening on any socket")));

Good but I don't like the wording of the error very much.  Maybe "could
not bind to any socket"?  Doesn't seem quite right either.  [thinks...]
There are really two cases here:
	* listen_addresses is empty and the machine doesn't have Unix
	  sockets
	* listen_addresses contains (only) bogus addresses, and the
	  machine doesn't have Unix sockets.
"not listening on any socket" seems to focus on the first case, "could
not bind to any socket" focuses on the second.  Can we cover both?

Please revise, and update the docs too.

			regards, tom lane

Re: listening addresses

От:
Andrew Dunstan <andrew@dunslane.net>
Дата:


Tom Lane wrote:

>Andrew Dunstan  writes:
>  
>
>>Submitted for review.
>>    
>>
>
>Okay, some random comments:
>
>  
>
>>! char	   *ListenAddresses = "localhost";
>>    
>>
>
>I think you made this mistake in the log_line_prefix patch too.  The
>contents of a GUC string var should always be either NULL or a pointer
>to a malloc'd string --- ergo, its initial state must be NULL.  It's
>pure luck that GUC doesn't dump core trying to free() this pointer.
>


Noted. Thanks.

>
>  
>
>>+ 	/* 
>>+ 	 * check if ListenAddresses is empty or all spaces
>>+ 	 */
>>    
>>
>
>Why do you need this test (or the NetServer bool) at all?  Just scan
>the string and bind to whatever it mentions.
>

It is used in the existing code to test if we can do SSL.

>
>BTW it'd be better to use isspace() instead of a hardwired test for ' '.
>  
>

Again, the existing code for VirtualHost uses hardcoded space. I don't 
mind adjusting it, but was following style in the surrounding code.

>  
>
>>! 		if (strcmp(ListenAddresses,"*") != 0)
>>    
>>
>
>This seems a bit nonrobust since it will fail if any whitespace is
>added.  I think it'd be better to test whether any individual hostname
>extracted from the string is '*'.
>

Agree with the first point, disagree with the second. What does it mean 
to specify "12.34.56.78 *"?  I think  "*" should be allowed only if it 
is the only entry in the list.

>
>  
>
>>+ 	if (ListenSocket[0] == -1)
>>+ 		ereport(FATAL,
>>+ 				(errmsg("not listening on any socket")));
>>    
>>
>
>Good but I don't like the wording of the error very much.  Maybe "could
>not bind to any socket"?  Doesn't seem quite right either.  [thinks...]
>There are really two cases here:
>	* listen_addresses is empty and the machine doesn't have Unix
>	  sockets
>	* listen_addresses contains (only) bogus addresses, and the
>	  machine doesn't have Unix sockets.
>"not listening on any socket" seems to focus on the first case, "could
>not bind to any socket" focuses on the second.  Can we cover both?
>


I will think about it. Bear in mind that they will have already had 
warnings about specific failures.

>
>Please revise, and update the docs too.
>

Will do.

Thanks

andrew



Re: listening addresses

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Andrew Dunstan  writes:
> Tom Lane wrote:
> + 	 * check if ListenAddresses is empty or all spaces
>>
>> Why do you need this test (or the NetServer bool) at all?  Just scan
>> the string and bind to whatever it mentions.

> It is used in the existing code to test if we can do SSL.

That test seems entirely bogus given the new dispensation that we are
not going to error out on bad entries in listen_addresses.  I'd counsel
just getting rid of it.

>> This seems a bit nonrobust since it will fail if any whitespace is
>> added.  I think it'd be better to test whether any individual hostname
>> extracted from the string is '*'.

> Agree with the first point, disagree with the second. What does it mean 
> to specify "12.34.56.78 *"?  I think  "*" should be allowed only if it 
> is the only entry in the list.

What does it mean to specify "12.34.56.78 12.34.56.78 12.34.56.78"?
If we want to prevent people from writing redundant listen_addresses
lists, we'll have to work a lot harder than this.  But I don't see the
point of trying.

			regards, tom lane

Re: listening addresses

От:
Andrew Dunstan <andrew@dunslane.net>
Дата:
Tom Lane wrote:

>
>Please revise, and update the docs too.
>
>  
>

Second attempt attached. The fatal message now reads "no configured 
listening socket available", but I am not wedded to the wording. I also 
was not sure how to mark up * in the docs.

cheers

andrew
Index: doc/src/sgml/runtime.sgml
===================================================================
RCS file: /projects/cvsroot/pgsql-server/doc/src/sgml/runtime.sgml,v
retrieving revision 1.251
diff -c -r1.251 runtime.sgml
*** doc/src/sgml/runtime.sgml	15 Mar 2004 17:57:51 -0000	1.251
--- doc/src/sgml/runtime.sgml	22 Mar 2004 17:26:36 -0000
***************
*** 571,588 ****
  
       
       
-      
-       tcpip_socket (boolean)
-       
-        
-         If this is true, then the server will accept TCP/IP connections.TCP/IP</></>
-         Otherwise only local Unix domain socket connections are
-         accepted. It is off by default. This option can only be set at
-         server start.
-        
-       
-      
-   
       
        max_connections (integer)
        
--- 571,576 ----
***************
*** 702,717 ****
        
       
  
!      
!       virtual_host (string)
        
         
!         Specifies the IP address(es) on which the server is
!         to listen for connections from client applications.  If specified,
!         it takes the form of a space-separated list of host names and/or
!         numeric IP addresses.  If the list is empty, the server listens
!         on all available addresses (including
!         localhost</>).
         
        
       
--- 690,707 ----
        
       
  
!      
!       listen_addresses (string)
        
         
! 	 Specifies the IP address(es) on which the server is
! 	 to listen for connections from client applications.  
! 	 The default is localhost</>.
! 	 The item takes the form of a space-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 at all.
         
        
       
***************
*** 3009,3019 ****
         
         
          
!         virtual_host = x</>
         
         
          
!         tcpip_socket = on</>
         
         
          
--- 2999,3009 ----
         
         
          
!         listen_addresses = x</>
         
         
          
!         listen_addresses = '*'</>
         
         
          
Index: src/backend/postmaster/postmaster.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/backend/postmaster/postmaster.c,v
retrieving revision 1.375
diff -c -r1.375 postmaster.c
*** src/backend/postmaster/postmaster.c	15 Mar 2004 16:18:42 -0000	1.375
--- src/backend/postmaster/postmaster.c	22 Mar 2004 17:26:38 -0000
***************
*** 149,155 ****
  /* The socket number we are listening for connections on */
  int			PostPortNumber;
  char	   *UnixSocketDir;
! char	   *VirtualHost;
  
  /*
   * MaxBackends is the limit on the number of backends we can start.
--- 149,155 ----
  /* The socket number we are listening for connections on */
  int			PostPortNumber;
  char	   *UnixSocketDir;
! char	   *ListenAddresses;
  
  /*
   * MaxBackends is the limit on the number of backends we can start.
***************
*** 202,208 ****
  static int	SendStop = false;
  
  /* still more option variables */
- bool		NetServer = false;	/* listen on TCP/IP */
  bool		EnableSSL = false;
  bool		SilentMode = false; /* silent mode (-S) */
  
--- 202,207 ----
***************
*** 513,522 ****
  				SetConfigOption("fsync", "false", PGC_POSTMASTER, PGC_S_ARGV);
  				break;
  			case 'h':
! 				SetConfigOption("virtual_host", optarg, PGC_POSTMASTER, PGC_S_ARGV);
  				break;
  			case 'i':
! 				SetConfigOption("tcpip_socket", "true", PGC_POSTMASTER, PGC_S_ARGV);
  				break;
  			case 'k':
  				SetConfigOption("unix_socket_directory", optarg, PGC_POSTMASTER, PGC_S_ARGV);
--- 512,521 ----
  				SetConfigOption("fsync", "false", PGC_POSTMASTER, PGC_S_ARGV);
  				break;
  			case 'h':
! 				SetConfigOption("listen_addresses", optarg, PGC_POSTMASTER, PGC_S_ARGV);
  				break;
  			case 'i':
! 				SetConfigOption("listen_addresses", "*", PGC_POSTMASTER, PGC_S_ARGV);
  				break;
  			case 'k':
  				SetConfigOption("unix_socket_directory", optarg, PGC_POSTMASTER, PGC_S_ARGV);
***************
*** 704,714 ****
  	 * 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
--- 703,708 ----
***************
*** 753,820 ****
  	for (i = 0; i < MAXLISTEN; i++)
  		ListenSocket[i] = -1;
  
! 	if (NetServer)
  	{
! 		if (VirtualHost && VirtualHost[0])
  		{
! 			char	   *curhost,
! 					   *endptr;
! 			char		c = 0;
! 
! 			curhost = VirtualHost;
! 			for (;;)
! 			{
! 				while (*curhost == ' ') /* skip any extra spaces */
! 					curhost++;
! 				if (*curhost == '\0')
! 					break;
! 				endptr = strchr(curhost, ' ');
! 				if (endptr)
! 				{
! 					c = *endptr;
! 					*endptr = '\0';
! 				}
  				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")));
  		}
  
  #ifdef USE_RENDEZVOUS
! 		if (rendezvous_name != NULL)
! 		{
! 			DNSServiceRegistrationCreate(rendezvous_name,
! 										 "_postgresql._tcp.",
! 										 "",
! 										 htonl(PostPortNumber),
! 										 "",
! 								 (DNSServiceRegistrationReply) reg_reply,
! 										 NULL);
! 		}
! #endif
  	}
  
  #ifdef HAVE_UNIX_SOCKETS
  	status = StreamServerPort(AF_UNIX, NULL,
--- 747,805 ----
  	for (i = 0; i < MAXLISTEN; i++)
  		ListenSocket[i] = -1;
  
! 	if (ListenAddresses)
  	{
! 		char	   *curhost,
! 			*endptr;
! 		char		c = 0;
! 
! 		curhost = ListenAddresses;
! 		for (;;)
  		{
! 			while (isspace(*curhost)) /* skip any extra spaces */
! 				curhost++;
! 			if (*curhost == '\0')
! 				break;
! 			endptr = curhost;
! 			while(*endptr != '\0' && !isspace(*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(WARNING,
! 						(errmsg("could not create listen socket for \"%s\"",
! 								curhost)));
! 			*endptr = c;
! 			if(c != '\0')
! 				curhost = endptr+1;
! 			else
! 				break;
  		}
+ 	}
  
  #ifdef USE_RENDEZVOUS
! 	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,830 ****
  							  UnixSocketDir,
  							  ListenSocket, MAXLISTEN);
  	if (status != STATUS_OK)
! 		ereport(FATAL,
  				(errmsg("could not create Unix-domain socket")));
  #endif
  
  	XLOGPathInit();
  
--- 807,823 ----
  							  UnixSocketDir,
  							  ListenSocket, MAXLISTEN);
  	if (status != STATUS_OK)
! 		ereport(WARNING,
  				(errmsg("could not create Unix-domain socket")));
  #endif
+ 
+     /*
+ 	 * check that we have some socket to talk on 
+ 	 */
+ 
+ 	if (ListenSocket[0] == -1)
+ 		ereport(FATAL,
+ 				(errmsg("no configured listening socket available")));
  
  	XLOGPathInit();
  
Index: src/backend/utils/misc/guc.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/backend/utils/misc/guc.c,v
retrieving revision 1.191
diff -c -r1.191 guc.c
*** src/backend/utils/misc/guc.c	22 Mar 2004 03:15:29 -0000	1.191
--- src/backend/utils/misc/guc.c	22 Mar 2004 17:26:39 -0000
***************
*** 444,457 ****
  		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
--- 444,449 ----
***************
*** 1711,1722 ****
  	},
  
  	{
! 		{"virtual_host", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
! 			gettext_noop("Sets the host name or IP address to listen to."),
  			NULL
  		},
! 		&VirtualHost,
! 		"", NULL, NULL
  	},
  
  	{
--- 1703,1714 ----
  	},
  
  	{
! 		{"listen_addresses", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
! 			gettext_noop("Sets the host name or IP addresses to listen to."),
  			NULL
  		},
! 		&ListenAddresses,
! 		"localhost", NULL, NULL
  	},
  
  	{
Index: src/backend/utils/misc/postgresql.conf.sample
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/backend/utils/misc/postgresql.conf.sample,v
retrieving revision 1.108
diff -c -r1.108 postgresql.conf.sample
*** src/backend/utils/misc/postgresql.conf.sample	15 Mar 2004 15:56:26 -0000	1.108
--- src/backend/utils/misc/postgresql.conf.sample	22 Mar 2004 17:26:40 -0000
***************
*** 27,33 ****
  
  # - Connection Settings -
  
- #tcpip_socket = false
  #max_connections = 100
  	# note: increasing max_connections costs about 500 bytes of shared
  	# memory per connection slot, in addition to costs from shared_buffers
--- 27,32 ----
***************
*** 37,43 ****
  #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 -
--- 36,43 ----
  #unix_socket_directory = ''
  #unix_socket_group = ''
  #unix_socket_permissions = 0777	# octal
! #listen_addresses = 'localhost'	# what interface to listen on; 
! 				# defaults to localhost, '*' = any
  #rendezvous_name = ''		# defaults to the computer name
  
  # - Security & Authentication -
Index: src/include/miscadmin.h
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/include/miscadmin.h,v
retrieving revision 1.153
diff -c -r1.153 miscadmin.h
*** src/include/miscadmin.h	10 Feb 2004 03:42:45 -0000	1.153
--- src/include/miscadmin.h	22 Mar 2004 17:26:40 -0000
***************
*** 212,218 ****
   *	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;
--- 212,217 ----
***************
*** 222,228 ****
  extern int	Unix_socket_permissions;
  extern char *Unix_socket_group;
  extern char *UnixSocketDir;
! extern char *VirtualHost;
  
  
  /*****************************************************************************
--- 221,227 ----
  extern int	Unix_socket_permissions;
  extern char *Unix_socket_group;
  extern char *UnixSocketDir;
! extern char *ListenAddresses;
  
  
  /*****************************************************************************

Re: listening addresses

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Andrew Dunstan  writes:
> Second attempt attached. The fatal message now reads "no configured 
> listening socket available", but I am not wedded to the wording. I also 
> was not sure how to mark up * in the docs.

Reviewed and committed.

I found a bunch more references in the docs to the postmaster -i and -h
switches, and I'm far from sure we've hit them all yet; anyone want to
make another pass to check?

Code-wise it looked great, except that you need to remember to cast the
argument of isspace() to unsigned char; on most machines with signed
chars, failing to do this causes big trouble for 8th-bit-set characters.

I went with "no socket configured to listen on" for the failure message,
but am not wedded to that either.

			regards, tom lane

Re: listening addresses

От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
Tom Lane wrote:
> Andrew Dunstan  writes:
> > Second attempt attached. The fatal message now reads "no configured 
> > listening socket available", but I am not wedded to the wording. I also 
> > was not sure how to mark up * in the docs.
> 
> Reviewed and committed.
> 
> I found a bunch more references in the docs to the postmaster -i and -h
> switches, and I'm far from sure we've hit them all yet; anyone want to
> make another pass to check?
> 
> Code-wise it looked great, except that you need to remember to cast the
> argument of isspace() to unsigned char; on most machines with signed
> chars, failing to do this causes big trouble for 8th-bit-set characters.
> 
> I went with "no socket configured to listen on" for the failure message,
> but am not wedded to that either.

I updated the error text to:

	        (errmsg("no socket configured for listening")));

Hope you like it.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: listening addresses

От:
"Andrew Dunstan" <andrew@dunslane.net>
Дата:
Bruce Momjian said:
> Tom Lane wrote:
>> Andrew Dunstan  writes:
>> > Second attempt attached. The fatal message now reads "no configured
>> > listening socket available", but I am not wedded to the wording. I
>> > also  was not sure how to mark up * in the docs.
>>
>> I went with "no socket configured to listen on" for the failure
>> message, but am not wedded to that either.
>
> I updated the error text to:
>
> 	        (errmsg("no socket configured for listening")));
>
> Hope you like it.
>

Both of these are not always correct - they might well have configured a
listening address but we were unable to bind to it, although in that case
a warning would have already been issued. To be strictly correct either we
need to use a flag to distinguish the these cases, or we need an error
message that contemplates both cases.

cheers

andrew


Re: listening addresses

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
"Andrew Dunstan"  writes:
> Both of these are not always correct - they might well have configured a
> listening address but we were unable to bind to it, although in that case
> a warning would have already been issued. To be strictly correct either we
> need to use a flag to distinguish the these cases, or we need an error
> message that contemplates both cases.

How about "no socket created for listening" or some such?

			regards, tom lane

Re: listening addresses

От:
Andrew Dunstan <andrew@dunslane.net>
Дата:
Tom Lane wrote:

>"Andrew Dunstan"  writes:
>  
>
>>Both of these are not always correct - they might well have configured a
>>listening address but we were unable to bind to it, although in that case
>>a warning would have already been issued. To be strictly correct either we
>>need to use a flag to distinguish the these cases, or we need an error
>>message that contemplates both cases.
>>    
>>
>
>How about "no socket created for listening" or some such?
>
>  
>

That works.

cheers

andrew

Re: listening addresses

От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
Tom Lane wrote:
> "Andrew Dunstan"  writes:
> > Both of these are not always correct - they might well have configured a
> > listening address but we were unable to bind to it, although in that case
> > a warning would have already been issued. To be strictly correct either we
> > need to use a flag to distinguish the these cases, or we need an error
> > message that contemplates both cases.
> 
> How about "no socket created for listening" or some such?

Or "no socket available for listening"?

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: listening addresses

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Bruce Momjian  writes:
> Tom Lane wrote:
>> How about "no socket created for listening" or some such?

> Or "no socket available for listening"?

"Created" seems better since it's a verb, and focuses attention on the
probability that we tried and failed to make a socket.  "Available" is
too passive; it seems to suggest that the problem is a kernel limitation
or some other outside force, when of course the problem is bogus
configuration parameters given us by the DBA.

But we've already spent far more time on this one message than is
justified ;-)

			regards, tom lane
FAQ