Re: [HACKERS] Proposed patch to getaddrinfo.c to support

From: "Chuck McDevitt" <cmcdevitt(at)greenplum(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Petr Jelinek" <pjmodos(at)seznam(dot)cz>
Cc: "Andrew Dunstan" <andrew(at)dunslane(dot)net>, pgsql-patches(at)postgresql(dot)org, dpage(at)vale-housing(dot)co(dot)uk, "Bruce Momjian" <pgman(at)candle(dot)pha(dot)pa(dot)us>
Subject: Re: [HACKERS] Proposed patch to getaddrinfo.c to support
Date: 2005-08-26 02:19:26
Message-ID: BB05A27C22288540A3A3E8F3749B45AB163FBC@MI8NYCMAIL06.Mi8.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

The "No error" message occurs because pqcomm.c assumes bind returns the
error code in "errno", but on Windows it gets returned by
"WSAGetLastError()". This bug probably exists in many places in the
code.

The actual error should have said:

LOG: could not bind IPv6 socket: The system detected an invalid pointer
address in attempting to use a pointer argument in a call.

It turns out the root of the bug is that our definition of "addrinfo"
and Windows definition of "addrinfo" are not the same.

Microsoft followed the IETF RFC 2553 paper and defined ai_canonname
before ai_addr,
While PostgreSQL picks up its address from the GNU GCC implementation
which incorrectly has them the other way around.

Because the pointers were defined in different orders, we got the wrong
one.

If you use the Microsoft header throughout (HAVE_STRUCT_ADDRINFO = 1),
You don't see this problem.

Now I just have to figure out a way to update the patch...

> -----Original Message-----
> From: Tom Lane [mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us]
> Sent: Thursday, August 25, 2005 2:51 PM
> To: Petr Jelinek
> Cc: Andrew Dunstan; pgsql-patches(at)postgresql(dot)org; dpage(at)vale-
> housing.co.uk; Bruce Momjian; Chuck McDevitt
> Subject: Re: [HACKERS] Proposed patch to getaddrinfo.c to support
>
> Petr Jelinek <pjmodos(at)seznam(dot)cz> writes:
> > Andrew Dunstan wrote:
> >> So, not quite there yet.
>
> > [I did make check only in W2K because I don't have direct access to
XP
> > machine now]
> > No thats not windows error thats postgres error (look at pqcomm.c),
> > which means HAVE_IPV6 is not defined.
>
> Possibly, but that's apparently not the only problem. I'm looking at
> the first buildfarm result with this patch,
> http://www.pgbuildfarm.org/cgi-bin/show_log.pl?nm=loris&dt=2005-08-
> 25%2018:56:02
>
> The interesting part is the postmaster log at the bottom:
>
> LOG: could not bind IPv4 socket: No error
> HINT: Is another postmaster already running on port 55678? If not,
wait a
> few seconds and retry.
> WARNING: could not create listen socket for "localhost"
> FATAL: could not create any TCP/IP sockets
>
> Apparently, access to IPv4 sockets isn't working either (and the "No
> error" isn't very helpful; would seem we're not reading the right
> status value).
>
> regards, tom lane

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2005-08-26 03:15:50 Re: [HACKERS] Proposed patch to getaddrinfo.c to support
Previous Message Andrew Dunstan 2005-08-25 23:03:05 Re: [HACKERS] Proposed patch to getaddrinfo.c to support