Re: PATCH: LWPng-alpha on Windows NT

Gisle Aas (gisle@aas.no)
05 Jul 1998 16:53:01 +0200


Blair Zajac <blair@gps.caltech.edu> writes:

> Gisle, again, could you put out a new LWPng-alpha 0.22 release soon?  I'm
> releasing another package that will need these patches installed and
> these patches will also allow WebFS::FileCopy to work on NT.

I am uploading LWPng-alpha-0.22 today.  I hope that it will work on NT
even if it is not based on your LWP::Extras patches.  I have no WinNT
machine to test it on.  The main change is that I have made the
LWP::Conn::_Connect class actually work, and both the HTTP and the
FTP module use it to connect now.

The IO::EINPROGRESS hack is now more forgiving. It goes like this:

# A hack that should work at least on systems with POSIX.pm.  It
# implements the constant EINPROGRESS and IO::Handle->blocking;
# XXX: When we require IO-1.18, then this hack can be removed.
require IO::Handle;
unless (defined &IO::EINPROGRESS) {
    eval {
        require POSIX;
        my $einprogress =  POSIX::EINPROGRESS();
        *IO::EINPROGRESS = sub () { $einprogress };

        # we also emulate $handle->blocking call provided by newer
        # versions of the IO modules
        require Fcntl;
        my $O_NONBLOCK = Fcntl::O_NONBLOCK();
        my $F_GETFL    = Fcntl::F_GETFL();
        my $F_SETFL    = Fcntl::F_SETFL();
        *IO::Handle::blocking = sub {
            my $fh = shift;
            my $dummy = '';
            my $old = fcntl($fh, $F_GETFL, $dummy);
            return undef unless defined $old;
            if (@_) {
                my $new = $old;
                if ($_[0]) {
                    $new &= ~$O_NONBLOCK;
                } else {
                    $new |= $O_NONBLOCK;
                }
                fcntl($fh, $F_SETFL, $new);
            }
            ($old & $O_NONBLOCK) == 0;
        }
    };
    if ($@) {
        # Give up, just make fake entries.  Things should still work,
        # but some event handlers might block when they should not.
        # This might reduce the amount of parallelism that can take place.
        *IO::EINPROGRESS = sub () { 0 };
        *IO::Handle::blocking = sub { };
    };
}

Regards,
Gisle