PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed: Invalid argument

Started by Kenji Sugitaover 22 years ago14 messages
#1Kenji Sugita
sugita@srapc1327.sra.co.jp

It seems that a value of addr->ai_socktype returned by getaddrinfo in
pg_stat.c is not SOCK_DGRAM.

Kenji Sugita

#2Kurt Roeckx
Q@ping.be
In reply to: Kenji Sugita (#1)
Re: PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed: Invalid argument

On Thu, Jul 03, 2003 at 10:44:31AM +0900, Kenji Sugita wrote:

From: Kurt Roeckx <Q@ping.be>
To: Kenji Sugita <sugita@srapc1327.sra.co.jp>
Cc: pgsql-hackers@postgresql.org
Date: Wed, 2 Jul 2003 19:20:11 +0200

;;; What system are you running on, and does it have a getaddrinfo()
;;; or not?

Red Hat Linux 6.2 and Mac OS X 10.2.6.

[...]

For Mac OS X it produces LOG: PGSTAT: socket() failed: Protocol not supported.

This looks a little broken behaviour to me. My guess is that it
returns an AF_INET6 socket but doesn't support it in the kernel.
In that case with the AI_ADDRCONFIG option it shouldn't have
returned that address. The question is wether your getaddrinfo()
supports that option, and wether it's working or not.

We can fix this by going over all the returned addresses until
one of the socket() calls works.

We probably should also skip AF_UNIX sockets, since that might
not be want we want.

$ postmaster (on Red Hat)
...
2003-07-03 10:19:38 [29761] LOG: XX000: PGSTAT: getaddrinfo2() failed: Name or service not known

That is just evil. It can't even resolv localhost? Do you have
a localhost entry in /etc/hosts?

If that's not the problem I see no other way but to use
INADDR_LOOPBACK and in6addr_loopback directly instead, which I
really hate.

What value shuld be passed to a following socket call with
addr->ai_socktype?

==== pgstats.c ====
if ((pgStatSock = socket(addr->ai_family,
addr->ai_socktype, addr->ai_protocol)) < 0)
{
elog(LOG, "PGSTAT: socket() failed: %m");
goto startup_failed;
}

The ai_family should be either AF_INET or AF_INET6, ai_socktype
should be SOCK_DGRAM, and ai_protocol 0 or IPPROTO_UDP.

Kurt

#3Noname
qhwt@myrealbox.com
In reply to: Kenji Sugita (#1)
Re: PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed: Invalid argument

Hi,

On Wed, Jul 02, 2003 at 03:49:19PM +0900, Kenji Sugita wrote:

It seems that a value of addr->ai_socktype returned by getaddrinfo in
pg_stat.c is not SOCK_DGRAM.

Please try the following untested patch:

--- pgstat.c.orig	Thu Jun 12 16:36:51 2003
+++ pgstat.c		Mon Jul  7 00:34:50 2003
@@ -194,10 +194,12 @@
 			gai_strerror(ret));
 		goto startup_failed;
 	}
-	
-	if ((pgStatSock = socket(addr->ai_family,
-		addr->ai_socktype, addr->ai_protocol)) < 0)
-	{
+
+	for (; addr != NULL; addr = addr->ai_next)
+		if ((pgStatSock = socket(addr->ai_family,
+			addr->ai_socktype, addr->ai_protocol)) >= 0)
+			break;
+	if (pgStatSock < 0) {
 		elog(LOG, "PGSTAT: socket() failed: %m");
 		goto startup_failed;
 	}
#4Noname
qhwt@myrealbox.com
In reply to: Noname (#3)
Re: PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed: Invalid argument

On Mon, Jul 07, 2003 at 12:38:57AM +0900, qhwt@myrealbox.com wrote:

Hi,

On Wed, Jul 02, 2003 at 03:49:19PM +0900, Kenji Sugita wrote:

It seems that a value of addr->ai_socktype returned by getaddrinfo in
pg_stat.c is not SOCK_DGRAM.

Please try the following untested patch:

No, please disregard the previous mail and try this one.

When hints.ai_family is PF_UNSPEC, getaddrinfo() returns two entries,
first one being IPv6 one, and the second one is IPv4 one, even if
IPv6 support is not compiled in the kernel(this is true at least on
my FreeBSD box).

--- pgstat.c	Thu Jun 12 16:36:51 2003
+++ pgstat.c	Mon Jul  7 00:49:07 2003
@@ -145,7 +145,7 @@
 pgstat_init(void)
 {
 	ACCEPT_TYPE_ARG3	alen;
-	struct	addrinfo	*addr, hints;
+	struct	addrinfo	*addr0, addr, hints;
 	int			ret;
 	/*
@@ -187,17 +187,19 @@
 	hints.ai_addr = NULL;
 	hints.ai_canonname = NULL;
 	hints.ai_next = NULL;
-	ret = getaddrinfo2("localhost", NULL, &hints, &addr);
-	if (ret || !addr)
+	ret = getaddrinfo2("localhost", NULL, &hints, &addr0);
+	if (ret || !addr0)
 	{
 		elog(LOG, "PGSTAT: getaddrinfo2() failed: %s",
 			gai_strerror(ret));
 		goto startup_failed;
 	}
-	
-	if ((pgStatSock = socket(addr->ai_family,
-		addr->ai_socktype, addr->ai_protocol)) < 0)
-	{
+
+	for (addr = addr0; addr != NULL; addr = addr->ai_next)
+		if ((pgStatSock = socket(addr->ai_family,
+			addr->ai_socktype, addr->ai_protocol)) >= 0)
+			break;
+	if (pgStatSock < 0) {
 		elog(LOG, "PGSTAT: socket() failed: %m");
 		goto startup_failed;
 	}
@@ -211,8 +213,8 @@
 		elog(LOG, "PGSTAT: bind() failed: %m");
 		goto startup_failed;
 	}
-	freeaddrinfo2(hints.ai_family, addr);
-	addr = NULL;
+	freeaddrinfo2(hints.ai_family, addr0);
+	addr0 = addr = NULL;

alen = sizeof(pgStatAddr);
if (getsockname(pgStatSock, (struct sockaddr *)&pgStatAddr, &alen) < 0)

#5Kurt Roeckx
Q@ping.be
In reply to: Noname (#3)
1 attachment(s)
Re: PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed: Invalid argument

On Mon, Jul 07, 2003 at 12:38:57AM +0900, qhwt@myrealbox.com wrote:

On Wed, Jul 02, 2003 at 03:49:19PM +0900, Kenji Sugita wrote:

It seems that a value of addr->ai_socktype returned by getaddrinfo in
pg_stat.c is not SOCK_DGRAM.

Please try the following untested patch:

[...]

+	for (; addr != NULL; addr = addr->ai_next)
+		if ((pgStatSock = socket(addr->ai_family,
+			addr->ai_socktype, addr->ai_protocol)) >= 0)
+			break;

This will break. You should use a pointer to the addr, and go
over the list using that.

freeaddrinfo() needs to have the original addr back.

He seems to have 2 problems:
- On Mac OS X getaddrinfo() returns something it shouldn't.
A patch like that could fix it.
- On Linux Redhat 6.2 (and 6.0) getaddrinfo() seems to have a
problem with AI_ADDRCONFIG. Which is also used in
StreamServerPort(). So he won't be able to listen to any
socket there either.

Not being able to use AI_ADDRCONFIG is rather annoying, but I
guess if we just try all the returned addresses until 1 works
will have to do.

Try the attached patch instead.

Kurt

Attachments:

pgstat.difftext/plain; charset=us-asciiDownload
Index: ./src/backend/postmaster/pgstat.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/backend/postmaster/pgstat.c,v
retrieving revision 1.37
diff -u -r1.37 pgstat.c
--- ./src/backend/postmaster/pgstat.c	12 Jun 2003 07:36:51 -0000	1.37
+++ ./src/backend/postmaster/pgstat.c	6 Jul 2003 16:27:20 -0000
@@ -146,6 +146,7 @@
 {
 	ACCEPT_TYPE_ARG3	alen;
 	struct	addrinfo	*addr, hints;
+	struct	addrinfo	*addrp;
 	int			ret;
 
 	/*
@@ -188,15 +189,38 @@
 	hints.ai_canonname = NULL;
 	hints.ai_next = NULL;
 	ret = getaddrinfo2("localhost", NULL, &hints, &addr);
-	if (ret || !addr)
+
+	addrp = addr;
+
+#ifdef	HAVE_UNIX_SOCKETS
+	/* Skip AF_UNIX sockets. */
+	if (!ret)
+	{
+		while (addrp && addrp->ai_family == AF_UNIX)
+		{
+			addrp = addrp->ai_next;
+		}
+	}
+#endif
+
+	if (ret || !addrp)
 	{
 		elog(LOG, "PGSTAT: getaddrinfo2() failed: %s",
 			gai_strerror(ret));
 		goto startup_failed;
 	}
+
 	
-	if ((pgStatSock = socket(addr->ai_family,
-		addr->ai_socktype, addr->ai_protocol)) < 0)
+	for (; addrp; addrp = addrp->ai_next)
+	{
+		if ((pgStatSock = socket(addrp->ai_family,
+			addrp->ai_socktype, addrp->ai_protocol)) >= 0)
+		{
+			break;
+		}
+	}
+
+	if (!addrp)
 	{
 		elog(LOG, "PGSTAT: socket() failed: %m");
 		goto startup_failed;
@@ -206,7 +230,7 @@
 	 * Bind it to a kernel assigned port on localhost and get the assigned
 	 * port via getsockname().
 	 */
-	if (bind(pgStatSock, addr->ai_addr, addr->ai_addrlen) < 0)
+	if (bind(pgStatSock, addrp->ai_addr, addrp->ai_addrlen) < 0)
 	{
 		elog(LOG, "PGSTAT: bind() failed: %m");
 		goto startup_failed;
Index: ./src/backend/libpq/pqcomm.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/backend/libpq/pqcomm.c,v
retrieving revision 1.157
diff -u -r1.157 pqcomm.c
--- ./src/backend/libpq/pqcomm.c	12 Jun 2003 07:36:51 -0000	1.157
+++ ./src/backend/libpq/pqcomm.c	6 Jul 2003 16:28:01 -0000
@@ -216,7 +216,7 @@
 	/* Initialize hint structure */
 	MemSet(&hint, 0, sizeof(hint));
 	hint.ai_family = family;
-	hint.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
+	hint.ai_flags = AI_PASSIVE;
 	hint.ai_socktype = SOCK_STREAM;
 
 #ifdef HAVE_UNIX_SOCKETS
#6Kurt Roeckx
Q@ping.be
In reply to: Noname (#4)
Re: PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed: Invalid argument

On Mon, Jul 07, 2003 at 12:55:06AM +0900, qhwt@myrealbox.com wrote:

When hints.ai_family is PF_UNSPEC, getaddrinfo() returns two entries,
first one being IPv6 one, and the second one is IPv4 one, even if
IPv6 support is not compiled in the kernel(this is true at least on
my FreeBSD box).

And that is why you have AI_ADDRCONFIG, which seems to be broken
for him.

Kurt

#7Kurt Roeckx
Q@ping.be
In reply to: Kurt Roeckx (#5)
1 attachment(s)
Re: PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed: Invalid argument

On Sun, Jul 06, 2003 at 06:30:04PM +0200, Kurt Roeckx wrote:

Try the attached patch instead.

Oops, that one was a little broken. I change it.

Try the attached one instead.

Kurt

Attachments:

pgstat.difftext/plain; charset=us-asciiDownload
Index: ./src/backend/postmaster/pgstat.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/backend/postmaster/pgstat.c,v
retrieving revision 1.37
diff -u -r1.37 pgstat.c
--- ./src/backend/postmaster/pgstat.c	12 Jun 2003 07:36:51 -0000	1.37
+++ ./src/backend/postmaster/pgstat.c	6 Jul 2003 16:42:52 -0000
@@ -145,7 +145,7 @@
 pgstat_init(void)
 {
 	ACCEPT_TYPE_ARG3	alen;
-	struct	addrinfo	*addr, hints;
+	struct	addrinfo	*addrs, *addr, hints;
 	int			ret;
 
 	/*
@@ -187,16 +187,32 @@
 	hints.ai_addr = NULL;
 	hints.ai_canonname = NULL;
 	hints.ai_next = NULL;
-	ret = getaddrinfo2("localhost", NULL, &hints, &addr);
-	if (ret || !addr)
+	ret = getaddrinfo2("localhost", NULL, &hints, &addrs);
+
+	if (ret || !addrs)
 	{
 		elog(LOG, "PGSTAT: getaddrinfo2() failed: %s",
 			gai_strerror(ret));
 		goto startup_failed;
 	}
 	
-	if ((pgStatSock = socket(addr->ai_family,
-		addr->ai_socktype, addr->ai_protocol)) < 0)
+	for (addr = addrs; addr; addr = addr->ai_next)
+	{
+#ifdef	HAVE_UNIX_SOCKETS
+		/* Skip AF_UNIX sockets. */
+		while (addr && addr->ai_family == AF_UNIX)
+		{
+			continue;
+		}
+#endif
+		if ((pgStatSock = socket(addr->ai_family,
+			addr->ai_socktype, addr->ai_protocol)) >= 0)
+		{
+			break;
+		}
+	}
+
+	if (!addr || pgStatSock < 0)
 	{
 		elog(LOG, "PGSTAT: socket() failed: %m");
 		goto startup_failed;
@@ -211,8 +227,8 @@
 		elog(LOG, "PGSTAT: bind() failed: %m");
 		goto startup_failed;
 	}
-	freeaddrinfo2(hints.ai_family, addr);
-	addr = NULL;
+	freeaddrinfo2(hints.ai_family, addrs);
+	addrs = NULL;
 
 	alen = sizeof(pgStatAddr);
 	if (getsockname(pgStatSock, (struct sockaddr *)&pgStatAddr, &alen) < 0)
@@ -257,9 +273,9 @@
 	return;
 
 startup_failed:
-	if (addr)
+	if (addrs)
 	{
-		freeaddrinfo2(hints.ai_family, addr);
+		freeaddrinfo2(hints.ai_family, addrs);
 	}
 
 	if (pgStatSock >= 0)
Index: ./src/backend/libpq/pqcomm.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/backend/libpq/pqcomm.c,v
retrieving revision 1.157
diff -u -r1.157 pqcomm.c
--- ./src/backend/libpq/pqcomm.c	12 Jun 2003 07:36:51 -0000	1.157
+++ ./src/backend/libpq/pqcomm.c	6 Jul 2003 16:42:58 -0000
@@ -216,7 +216,7 @@
 	/* Initialize hint structure */
 	MemSet(&hint, 0, sizeof(hint));
 	hint.ai_family = family;
-	hint.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
+	hint.ai_flags = AI_PASSIVE;
 	hint.ai_socktype = SOCK_STREAM;
 
 #ifdef HAVE_UNIX_SOCKETS
#8Kenji Sugita
sugita@sra.co.jp
In reply to: Kurt Roeckx (#7)
Re: PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed:

From: Kurt Roeckx <Q@ping.be>
Subject: Re: [HACKERS] PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed: Invalid argument
Date: Sun, 6 Jul 2003 18:44:35 +0200

;;; On Sun, Jul 06, 2003 at 06:30:04PM +0200, Kurt Roeckx wrote:
;;; > Try the attached patch instead.
;;;
;;; Oops, that one was a little broken. I change it.
;;;
;;; Try the attached one instead.

I tried the newest one.

==== Red Hat 6.2
$ postmaster
# Waiting forever

$ top
11:24am up 276 days, 14:12, 2 users, load average: 0.90, 0.66, 0.35
46 processes: 44 sleeping, 2 running, 0 zombie, 0 stopped
CPU states: 49.6% user, 0.8% system, 0.0% nice, 49.5% idle
Mem: 2009220K av, 1544312K used, 464908K free, 37792K shrd, 1402556K buff
Swap: 265064K av, 4024K used, 261040K free 78444K cached

PID USER PRI NI SIZE RSS SHARE STAT LIB %CPU %MEM TIME COMMAND
12074 sugita 10 0 1668 1668 1328 R 0 99.2 0.0 1:00 postmaster
..

==== Mac OS X 10.2.6
$ postmaster
2003-07-08 11:48:32 [1512] LOG: PGSTAT: socket() failed: Protocol not supported

Kenji Sugita

#9Kenji Sugita
sugita@srapc1327.sra.co.jp
In reply to: Kurt Roeckx (#7)
Re: PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed:

From: Kurt Roeckx <Q@ping.be>
Subject: Re: [HACKERS] PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed: Invalid argument
Date: Sun, 6 Jul 2003 18:44:35 +0200

;;; On Sun, Jul 06, 2003 at 06:30:04PM +0200, Kurt Roeckx wrote:
;;; > Try the attached patch instead.
;;;
;;; Oops, that one was a little broken. I change it.
;;;
;;; Try the attached one instead.

I tried the newest one.

==== Red Hat 6.2
$ postmaster
# Waiting forever

$ top
11:24am up 276 days, 14:12, 2 users, load average: 0.90, 0.66, 0.35
46 processes: 44 sleeping, 2 running, 0 zombie, 0 stopped
CPU states: 49.6% user, 0.8% system, 0.0% nice, 49.5% idle
Mem: 2009220K av, 1544312K used, 464908K free, 37792K shrd, 1402556K buff
Swap: 265064K av, 4024K used, 261040K free 78444K cached

PID USER PRI NI SIZE RSS SHARE STAT LIB %CPU %MEM TIME COMMAND
12074 sugita 10 0 1668 1668 1328 R 0 99.2 0.0 1:00 postmaster
..

==== Mac OS X 10.2.6
$ postmaster
2003-07-08 11:48:32 [1512] LOG: PGSTAT: socket() failed: Protocol not supported

Kenji Sugita

In reply to: Kenji Sugita (#9)
1 attachment(s)
Re: PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed:

On Tue, Jul 08, 2003 at 12:34:19PM +0900, Kenji Sugita wrote:

From: Kurt Roeckx <Q@ping.be>
Subject: Re: [HACKERS] PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed: Invalid argument
Date: Sun, 6 Jul 2003 18:44:35 +0200

;;; On Sun, Jul 06, 2003 at 06:30:04PM +0200, Kurt Roeckx wrote:
;;; > Try the attached patch instead.
;;;
;;; Oops, that one was a little broken. I change it.
;;;
;;; Try the attached one instead.

I tried the newest one.

I did some investigation on a redhat 6.0. It seems getaddrinfo
is really broken.

It returns an AF_INET socket, but it doesn't say it should be of
socket type SOCK_DGRAM. It also returns an AF_UNIX socket and
for that it sets the socktype correct, but we don't want to use
the AF_UNIX one.

I'm going to assume that Mac Os X is broken in the same way.

Here is a new patch.

Kurt

Attachments:

pgstat.difftext/plain; charset=us-asciiDownload
Index: ./src/backend/postmaster/pgstat.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/backend/postmaster/pgstat.c,v
retrieving revision 1.37
diff -u -r1.37 pgstat.c
--- ./src/backend/postmaster/pgstat.c	12 Jun 2003 07:36:51 -0000	1.37
+++ ./src/backend/postmaster/pgstat.c	8 Jul 2003 20:24:20 -0000
@@ -145,7 +145,7 @@
 pgstat_init(void)
 {
 	ACCEPT_TYPE_ARG3	alen;
-	struct	addrinfo	*addr, hints;
+	struct	addrinfo	*addrs, *addr, hints;
 	int			ret;
 
 	/*
@@ -187,16 +187,32 @@
 	hints.ai_addr = NULL;
 	hints.ai_canonname = NULL;
 	hints.ai_next = NULL;
-	ret = getaddrinfo2("localhost", NULL, &hints, &addr);
-	if (ret || !addr)
+	ret = getaddrinfo2("localhost", NULL, &hints, &addrs);
+
+	if (ret || !addrs)
 	{
 		elog(LOG, "PGSTAT: getaddrinfo2() failed: %s",
 			gai_strerror(ret));
 		goto startup_failed;
 	}
 	
-	if ((pgStatSock = socket(addr->ai_family,
-		addr->ai_socktype, addr->ai_protocol)) < 0)
+	for (addr = addrs; addr; addr = addr->ai_next)
+	{
+#ifdef	HAVE_UNIX_SOCKETS
+		/* Skip AF_UNIX sockets. */
+		if (addr->ai_family == AF_UNIX)
+		{
+			continue;
+		}
+#endif
+		if ((pgStatSock = socket(addr->ai_family,
+			SOCK_DGRAM, 0)) >= 0)
+		{
+			break;
+		}
+	}
+
+	if (!addr || pgStatSock < 0)
 	{
 		elog(LOG, "PGSTAT: socket() failed: %m");
 		goto startup_failed;
@@ -211,8 +227,8 @@
 		elog(LOG, "PGSTAT: bind() failed: %m");
 		goto startup_failed;
 	}
-	freeaddrinfo2(hints.ai_family, addr);
-	addr = NULL;
+	freeaddrinfo2(hints.ai_family, addrs);
+	addrs = NULL;
 
 	alen = sizeof(pgStatAddr);
 	if (getsockname(pgStatSock, (struct sockaddr *)&pgStatAddr, &alen) < 0)
@@ -257,9 +273,9 @@
 	return;
 
 startup_failed:
-	if (addr)
+	if (addrs)
 	{
-		freeaddrinfo2(hints.ai_family, addr);
+		freeaddrinfo2(hints.ai_family, addrs);
 	}
 
 	if (pgStatSock >= 0)
Index: ./src/backend/libpq/pqcomm.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/backend/libpq/pqcomm.c,v
retrieving revision 1.157
diff -u -r1.157 pqcomm.c
--- ./src/backend/libpq/pqcomm.c	12 Jun 2003 07:36:51 -0000	1.157
+++ ./src/backend/libpq/pqcomm.c	8 Jul 2003 20:24:35 -0000
@@ -216,7 +216,7 @@
 	/* Initialize hint structure */
 	MemSet(&hint, 0, sizeof(hint));
 	hint.ai_family = family;
-	hint.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
+	hint.ai_flags = AI_PASSIVE;
 	hint.ai_socktype = SOCK_STREAM;
 
 #ifdef HAVE_UNIX_SOCKETS
@@ -266,8 +266,7 @@
 			/* Nothing found. */
 			break;
 		}
-		if ((fd = socket(addr->ai_family, addr->ai_socktype,
-			addr->ai_protocol)) < 0)
+		if ((fd = socket(addr->ai_family, SOCK_STREAM, 0)) < 0)
 		{
 			elog(LOG, "server socket failure: socket(): %s",
 				 strerror(errno));
#11Kenji Sugita
sugita@srapc1327.sra.co.jp
In reply to: Kurt Roeckx (#10)
Re: PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed:

From: Kurt Roeckx <Q@ping.be>
Subject: Re: [HACKERS] PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed:
Date: Tue, 8 Jul 2003 22:25:44 +0200

;;; > ;;; On Sun, Jul 06, 2003 at 06:30:04PM +0200, Kurt Roeckx wrote:
;;; > ;;; > Try the attached patch instead.
;;; > ;;;
;;; > ;;; Oops, that one was a little broken. I change it.
;;; > ;;;
;;; > ;;; Try the attached one instead.
;;; >
;;; > I tried the newest one.
;;;
;;; I did some investigation on a redhat 6.0. It seems getaddrinfo
;;; is really broken.

----------------------------------------------------------------

;;; It returns an AF_INET socket, but it doesn't say it should be of
;;; socket type SOCK_DGRAM.

I pointed it in the first post. Rturned type is not SOCK_DGRAM.

;;; It also returns an AF_UNIX socket and
;;; for that it sets the socktype correct, but we don't want to use
;;; the AF_UNIX one.
;;;
;;; I'm going to assume that Mac Os X is broken in the same way.
;;;
;;; Here is a new patch.

It works on both platforms.

Thanks.

Kenji Sugita

#12Noname
qhwt@myrealbox.com
In reply to: Kurt Roeckx (#6)
Re: PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed: Invalid argument

Hello,

On Mon, Jul 07, 2003 at 12:55:06AM +0900, qhwt@myrealbox.com wrote:

When hints.ai_family is PF_UNSPEC, getaddrinfo() returns two entries,
first one being IPv6 one, and the second one is IPv4 one, even if
IPv6 support is not compiled in the kernel(this is true at least on
my FreeBSD box).

Sorry, this turned out to be bogus; AI_ADDRCONFIG flag was already present as
early as FreeBSD 4.3-RELEASE, but I forgot adding the flag in my test code.
The flag is not documented in the getaddrinfo(3) man page.

On Sun, Jul 06, 2003 at 06:35:52PM +0200, Kurt Roeckx wrote:

And that is why you have AI_ADDRCONFIG, which seems to be broken
for him.

I doubt RedHat 6 or MacOS X really support AI_ADDRCONFIG. Is it actually
defined somewhere in the system headers? Anyway it seems like its absence
is hidden by the following lines:

src/include/libpq/pqcomm.h:
85-/* Some systems don't have it, so default it to 0 so it doesn't
86- * have any effect on those systems. */
87:#ifndef AI_ADDRCONFIG
88:#define AI_ADDRCONFIG 0
89-#endif

#13Bruce Momjian
pgman@candle.pha.pa.us
In reply to: Kurt Roeckx (#10)
Re: PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed:

Your patch has been added to the PostgreSQL unapplied patches list at:

http://momjian.postgresql.org/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

---------------------------------------------------------------------------

Kurt Roeckx wrote:

On Tue, Jul 08, 2003 at 12:34:19PM +0900, Kenji Sugita wrote:

From: Kurt Roeckx <Q@ping.be>
Subject: Re: [HACKERS] PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed: Invalid argument
Date: Sun, 6 Jul 2003 18:44:35 +0200

;;; On Sun, Jul 06, 2003 at 06:30:04PM +0200, Kurt Roeckx wrote:
;;; > Try the attached patch instead.
;;;
;;; Oops, that one was a little broken. I change it.
;;;
;;; Try the attached one instead.

I tried the newest one.

I did some investigation on a redhat 6.0. It seems getaddrinfo
is really broken.

It returns an AF_INET socket, but it doesn't say it should be of
socket type SOCK_DGRAM. It also returns an AF_UNIX socket and
for that it sets the socktype correct, but we don't want to use
the AF_UNIX one.

I'm going to assume that Mac Os X is broken in the same way.

Here is a new patch.

Kurt

[ Attachment, skipping... ]

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

-- 
  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
#14Bruce Momjian
pgman@candle.pha.pa.us
In reply to: Kurt Roeckx (#10)
Re: PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed:

Already applied by Tom. Thanks.

---------------------------------------------------------------------------

Kurt Roeckx wrote:

On Tue, Jul 08, 2003 at 12:34:19PM +0900, Kenji Sugita wrote:

From: Kurt Roeckx <Q@ping.be>
Subject: Re: [HACKERS] PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed: Invalid argument
Date: Sun, 6 Jul 2003 18:44:35 +0200

;;; On Sun, Jul 06, 2003 at 06:30:04PM +0200, Kurt Roeckx wrote:
;;; > Try the attached patch instead.
;;;
;;; Oops, that one was a little broken. I change it.
;;;
;;; Try the attached one instead.

I tried the newest one.

I did some investigation on a redhat 6.0. It seems getaddrinfo
is really broken.

It returns an AF_INET socket, but it doesn't say it should be of
socket type SOCK_DGRAM. It also returns an AF_UNIX socket and
for that it sets the socktype correct, but we don't want to use
the AF_UNIX one.

I'm going to assume that Mac Os X is broken in the same way.

Here is a new patch.

Kurt

[ Attachment, skipping... ]

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

-- 
  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