On Thu, Apr 14, 2016 at 8:46 AM, Tom Lane <t...@sss.pgh.pa.us> wrote:
> Alvaro Herrera <alvhe...@2ndquadrant.com> writes:
>> Michael Paquier wrote:
>>> Well, yes. That's true, we could do without. Even if this could give
>>> an indication about a node running, as long as a port has been
>>> associated to a node once, we just need to be sure that a new port is
>>> not allocated. On Windows, I am not sure that it is worth the
>>> complication to be honest, and the current code gives a small safety
>>> net, which is better than nothing.
>> If we need to fix the test so that it works in a wider environment for
>> Windows, I don't think it makes sense to remove anything -- rather we
>> should change the test as Tom suggests to verify that the port is really
>> free rather than just doing the pg_isready test.  Maybe the additional
>> test will be useless in non-Windows environment, but why cares?  It will
>> work all the same.
> I think Michael is arguing that it's not worth fixing.  He might be right;
> it's not like this is the only cause of irreproducible failures on the
> Windows critters.  Still, it bugs me if we know how to make the regression
> tests more reliable and do not do so.  Back when I packaged mysql for Red
> Hat, I was constantly annoyed by how often their tests failed under load.
> Don't want to be like that.

Some experiment is proving that it is actually not that complicated to
make that cross-platform:
use Socket;

my $remote = 'localhost';
my $port = 5432;
$iaddr   = inet_aton($remote);
$paddr   = sockaddr_in($port, $iaddr);
$proto   = getprotobyname("tcp");
socket(SOCK, PF_INET, SOCK_STREAM, $proto)  || die "socket: $!";
connect(SOCK, $paddr)               || die "connect: $!";
close (SOCK)                        || die "close: $!";

IO::Socket::INET is another option, but I am not seeing it in perl <
5.12, and that's not part of ActivePerl, which makes life harder on
Windows. Socket is available on both. Does that address your concerns?

Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:

Reply via email to