develooper Front page | perl.perl5.porters | Postings from October 2014

Re: [MSWin32] I need help with RT#98976

Thread Previous | Thread Next
Craig A. Berry
October 2, 2014 13:38
Re: [MSWin32] I need help with RT#98976
Message ID:
On Tue, Sep 30, 2014 at 10:01 PM, Craig A. Berry
<> wrote:
> On Mon, Sep 29, 2014 at 9:42 AM, Paul "LeoNerd" Evans
> <> wrote:
>> t/22timeout.t is failing on MSWin32, and as is typical with such
>> failures I have no idea why nor have direct access to any resource to
>> test this with.
>> Can anyone offer assistance? This is a dual-life core module so it's
>> currently breaking blead.
> Haven't had a chance to fire up a Windows build, but FWIW it also
> fails on VMS.  Changing IO::Socket::IP to IO::Socket::INET makes it
> work fine.  As does removing the timeout.  The symptom is different
> from Windows; rather than an invalid file descriptor the connect
> attempt actually does fail with "connection timed out."  Increasing
> the timeout just makes it wait longer before failing.  Don't know why
> yet, but given the above points I'd suspect something about the way
> the timeout is being set up in IO::Socket::IP.  Hope to debug further
> at some point, and of course there's no guarantee the underlying issue
> is the same as on Windows.

It looks like a race condition in IO::Socket::IP::connect, which calls
CORE::connect, gets EINPROGRESS, then sets up a select to implement
the timeout that waits for the connection to complete.  The select
always times out because the connection completes in between calling
CORE::connect and select so there is never any activity on the socket
that would make the select fire.  The following seems to fix it:

--- lib/IO/Socket/;-0 2014-09-13 14:09:09 -0500
+++ lib/IO/Socket/ 2014-10-02 07:58:46 -0500
@@ -684,6 +684,10 @@ sub connect

       my $vec = ''; vec( $vec, $self->fileno, 1 ) = 1;
+      # Check one more time if connected before waiting.
+      return 1 if $self->connected();
       if( !select( $vec, $vec, $vec, $timeout ) ) {
          $! = ETIMEDOUT;
          return undef;

Don't know if that's really a correct or robust solution or whether it
will do anything for Windows.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About