In version 2.49 of Parallel::UserAgent.pm there is a bug in the way
timeouts are handled in &wait().

The problem lies here:
> ATTEMPT:
>  while ( $active = scalar keys %{ $self->{'current_connections'} }  or
>          $pending = scalar ($self->{'handle_in_order'}?
>                             @{ $self->{'ordpend_connections'} } :
>                             keys %{ $self->{'pending_connections'} } ) ) {
>    # check select
>    if ( (scalar $fh_in->handles) or (scalar $fh_out->handles) ) {
>      LWP::Debug::debug("Selecting Sockets, timeout is $timeout seconds");
>      unless ( @ready = IO::Select->select ($fh_in, $fh_out,
>                                            undef, $timeout) ) {
>        #
>        # empty array, means that select timed out
>        LWP::Debug::trace('select timeout');

The timeout only occurs if a single call to select times out.
However, select can be called over and over again, but these delays
are not counted against the timeout.  Thus it is possible, even
common, for the time to greatly exceed the specified timeout value.

The diff below seems to fix the problem.  This code has been used for
awhile and seems to be okay, but I don't know this module well so it's
possible a problem was introduced.
   
Tony

---------------------------------------------
865a866
>   my($start) = time;
873,874c874,876
<       unless ( @ready = IO::Select->select ($fh_in, $fh_out,
<                                           undef, $timeout) ) {
---
>       @ready = IO::Select->select ($fh_in, $fh_out, undef, 1);
>       my($elapsed) = time - $start;
>       unless ( $elapsed < $timeout ) {
903c905
<       } else {
---
>       } elsif( @ready ) {

Reply via email to