Skip to content

Commit 9234591

Browse files
committed
Include 'IPv4', 'IPv6', or 'Unix' in socket-creation failure messages,
in hopes of soothing fears of those with partial IPv6 support. Still an open question whether we should report EAFNOSUPPORT errors at all, though.
1 parent 90ade5b commit 9234591

File tree

1 file changed

+37
-5
lines changed

1 file changed

+37
-5
lines changed

src/backend/libpq/pqcomm.c

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
3131
* Portions Copyright (c) 1994, Regents of the University of California
3232
*
33-
* $Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.164 2003/08/07 19:37:13 tgl Exp $
33+
* $Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.165 2003/08/12 22:42:01 tgl Exp $
3434
*
3535
*-------------------------------------------------------------------------
3636
*/
@@ -209,7 +209,9 @@ StreamServerPort(int family, char *hostName, unsigned short portNumber,
209209
int maxconn;
210210
int one = 1;
211211
int ret;
212-
char portNumberStr[64];
212+
char portNumberStr[32];
213+
const char *familyDesc;
214+
char familyDescBuf[64];
213215
char *service;
214216
struct addrinfo *addrs = NULL,
215217
*addr;
@@ -276,11 +278,37 @@ StreamServerPort(int family, char *hostName, unsigned short portNumber,
276278
break;
277279
}
278280

281+
/* set up family name for possible error messages */
282+
switch (addr->ai_family)
283+
{
284+
case AF_INET:
285+
familyDesc = gettext("IPv4");
286+
break;
287+
#ifdef HAVE_IPV6
288+
case AF_INET6:
289+
familyDesc = gettext("IPv6");
290+
break;
291+
#endif
292+
#ifdef HAVE_UNIX_SOCKETS
293+
case AF_UNIX:
294+
familyDesc = gettext("Unix");
295+
break;
296+
#endif
297+
default:
298+
snprintf(familyDescBuf, sizeof(familyDescBuf),
299+
gettext("unrecognized address family %d"),
300+
addr->ai_family);
301+
familyDesc = familyDescBuf;
302+
break;
303+
}
304+
279305
if ((fd = socket(addr->ai_family, SOCK_STREAM, 0)) < 0)
280306
{
281307
ereport(LOG,
282308
(errcode_for_socket_access(),
283-
errmsg("failed to create socket: %m")));
309+
/* translator: %s is IPv4, IPv6, or Unix */
310+
errmsg("could not create %s socket: %m",
311+
familyDesc)));
284312
continue;
285313
}
286314

@@ -323,7 +351,9 @@ StreamServerPort(int family, char *hostName, unsigned short portNumber,
323351
{
324352
ereport(LOG,
325353
(errcode_for_socket_access(),
326-
errmsg("failed to bind server socket: %m"),
354+
/* translator: %s is IPv4, IPv6, or Unix */
355+
errmsg("could not bind %s socket: %m",
356+
familyDesc),
327357
(IS_AF_UNIX(addr->ai_family)) ?
328358
errhint("Is another postmaster already running on port %d?"
329359
" If not, remove socket node \"%s\" and retry.",
@@ -361,7 +391,9 @@ StreamServerPort(int family, char *hostName, unsigned short portNumber,
361391
{
362392
ereport(LOG,
363393
(errcode_for_socket_access(),
364-
errmsg("failed to listen on server socket: %m")));
394+
/* translator: %s is IPv4, IPv6, or Unix */
395+
errmsg("could not listen on %s socket: %m",
396+
familyDesc)));
365397
closesocket(fd);
366398
continue;
367399
}

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