Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id DF6C1B5DBC0 for ; Fri, 17 Jun 2011 14:52:12 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 75338-02 for ; Fri, 17 Jun 2011 17:52:06 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id A606FB5D801 for ; Fri, 17 Jun 2011 14:52:06 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p5HHpxkn020340; Fri, 17 Jun 2011 13:51:59 -0400 (EDT) To: "Marinos Yannikos" cc: "PostgreSQL Bugs" Subject: Re: Ident authentication fails due to bind error on server (8.4.8) In-reply-to: <17691.1308325281@sss.pgh.pa.us> References: <17691.1308325281@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Fri, 17 Jun 2011 11:41:21 -0400" Date: Fri, 17 Jun 2011 13:51:59 -0400 Message-ID: <20339.1308333119@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201106/154 X-Sequence-Number: 30533 I wrote: > I don't think it's a race condition per se. The code ought to be > setting up the address argument for bind() with sin_port = 0 so that > an unused port number gets assigned. That seems to be what happens on > a couple of machines that I tried here, but I notice that the Linux > manpage for getaddrinfo says > service sets the port in each returned address structure. If > this argument is a service name (see services(5)), it is > translated to the corresponding port number. This argument can > also be specified as a decimal number, which is simply converted > to binary. If service is NULL, then the port number of the > returned socket addresses will be left uninitialized. > In principle this wording would allow getaddrinfo to return the same > nonzero port number in multiple backends, which would lead to the > reported failure if they were doing ident verification at the same time. > I'm thinking maybe we should explicitly pass "0" rather than NULL to > getaddrinfo here. On the other hand, it seems to work reliably as-is > on my Linux machine, so this is just speculation at this point. I looked at the glibc source code for getaddrinfo, and it looks like they do reliably set sin_port to zero when no service argument is provided, despite the above documentation statement. So that's why it works for me. But still, if you're on a non-Linux platform it seems possible that this is the mechanism for what's biting you. regards, tom lane