Re: PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed: Invalid argument - Mailing list pgsql-hackers

From Kurt Roeckx
Subject Re: PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed: Invalid argument
Date
Msg-id 20030703204355.GA12774@ping.be
Whole thread Raw
In response to PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed: Invalid argument  (Kenji Sugita <sugita@srapc1327.sra.co.jp>)
List pgsql-hackers
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



pgsql-hackers by date:

Previous
From: "scott.marlowe"
Date:
Subject: Re: Are we backwards on the sign of timezones?
Next
From: "Dave Page"
Date:
Subject: Re: [pgadmin-support] [GENERAL] pgAdmin III - Call for Translators