Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 23 Dec 2003 14:20:04 -0800
From:      "Chris Ochs" <freebsd-current@paymentonline.net>
To:        <freebsd-current@freebsd.org>
Subject:   Perl IO::Handle/Socket behavior 5.2 vs 4.9
Message-ID:  <107101c3c9a2$ea92a5b0$9e042804@chris2>

next in thread | raw e-mail | index | archive | help
This code is in the Memcached.pm module that connects to the memcached
deamon (memcached is in ports).

On 5.2 the connect returns null unless I comment out the lines calling
IO::Handle::blocking.  On 4.9 it works fine.  Any ideas why?

Chris


sub _connect_sock { # sock, sin, timeout
    my ($sock, $sin, $timeout) = @_;
    $timeout ||= 0.25;

    my $block = IO::Handle::blocking($sock, 0) if $timeout;

    my $ret = connect($sock, $sin);

    if (!$ret && $timeout && $!{'EINPROGRESS'}) {

        my $win='';
        vec($win, fileno($sock), 1) = 1;

        if (select(undef, $win, undef, $timeout) > 0) {
            $ret = connect($sock, $sin);
            # EISCONN means connected & won't re-connect, so success
            $ret = 1 if !$ret && $!{'EISCONN'};
        }
    }

    IO::Handle::blocking($sock, $block) if $timeout;
    return $ret;
}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?107101c3c9a2$ea92a5b0$9e042804>