Re: PATCH: LWPng-alpha on Windows NT
Gisle Aas (gisle@aas.no)
03 Jul 1998 14:34:29 +0200
Blair Zajac <blair@gps.caltech.edu> writes:
> I've completed porting LWPng-alpha to Windows NT.
Very nice!
> I'm including below the complete patch for LWPng-alpha 0.21. It
> fixes a few things:
>
> 1) Add LWP::Extras that calculates EINPROGRESS and defines
> IO::Handle::blocking.
> 2) Replace the EINPROGRESS and IO::Handle::blocking code from LWP::Conn::HTTP
> and LWP::Conn::_Connet with use LWP::Extras.
> 3) Have LWPng-alpha/Makefile.PL require LWP 5.33.
I have some touble with this. I would really like to avoid adding XS
code to LWP and I don't really like the LWP::Extras name either.
Wouldn't it be much better to just say that you need IO-1.19 installed
to make it work on WinNT?
Does IO-1.19 work on WinNT?
> 4) In LWP::Conn::FILE test for the existence of getpwuid and getgrgid. These
> were causing the main failures of LWPng on NT.
This part of patch has been applied.
> 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 would also like to see it work on NT, but I would prefer if we just
made the IO modules do the work.
... or just test $^O and hardcode some EINPROGRESS that works for
WinNT?
Regards,
Gisle
> diff -rcN ../LWPng-alpha-0.21-orig/Extras/Extras.pm ./Extras/Extras.pm
> *** ../LWPng-alpha-0.21-orig/Extras/Extras.pm Wed Dec 31 17:00:00 1969
> --- ./Extras/Extras.pm Thu Jul 2 23:38:01 1998
> ***************
> *** 0 ****
> --- 1,132 ----
> + package LWP::Extras;
> +
> + use strict;
> + use vars qw($VERSION @ISA);
> +
> + use Exporter;
> + use DynaLoader;
> + use IO::Handle;
> +
> + @ISA = qw(Exporter DynaLoader);
> + $VERSION = '0.01';
> +
> + # Here we load the constant subroutines from the XS module.
> + bootstrap LWP::Extras $VERSION;
> +
> + # Here we define the subroutine IO::EINPROGRESS and emulate the
> + # $handle->blocking call provided by newer versions of the IO
> + # module. This will not be needed when we require IO-1.18 or
> + # greater.
> +
> + # &IO::EINPROGRESS is not defined in IO versions older than 1.18.
> + unless (defined &IO::EINPROGRESS) {
> + my $einprogress = -1;
> +
> + if (defined &LWP::Extras::EINPROGRESS) {
> + # Try to use LWP::Extras::EINPROGRESS.
> + $einprogress = &LWP::Extras::EINPROGRESS;
> + }
> + else {
> + # Otherwise try to use POSIX.
> + eval {
> + require POSIX;
> + $einprogress = &POSIX::EINPROGRESS;
> + };
> + $! = $einprogress;
> + die "The system constant EINPROGRESS cannot be found ($!)" if ($@ or $! ne "Operation now in progress");
> + }
> + *IO::EINPROGRESS = sub () { $einprogress; };
> + }
> +
> + # Emulate $handle->blocking call provided by newer versions of the IO modules.
> + unless (defined &IO::Handle::blocking) {
> + my ($O_NONBLOCK, $F_GETFL, $F_SETFL);
> + eval {
> + require Fcntl;
> + $O_NONBLOCK = Fcntl::O_NONBLOCK();
> + $F_GETFL = Fcntl::F_GETFL();
> + $F_SETFL = Fcntl::F_SETFL();
> + };
> + unless ($@) {
> + # We got the Fcntl constants OK.
> + *IO::Handle::blocking = sub {
> + my $fh = shift;
> + my $dummy = '';
> + my $old = fcntl($fh, $F_GETFL, $dummy);
> + return 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;
> + }
> + }
> + else {
> + # We do not have Fcntl constants. We'll implement the blocking
> + # method call but it will not do anything.
> + *IO::Handle::blocking = sub {
> + return;
> + }
> + }
> + }