develooper Front page | perl.libwww | Postings from August 2001

Re: [PATCH] Resolve "Short Write"

Thread Previous | Thread Next
From:
Gisle Aas
Date:
August 7, 2001 11:03
Subject:
Re: [PATCH] Resolve "Short Write"
Message ID:
lr7kwfkatj.fsf@caliper.ActiveState.com
Norton Allen <allen@huarp.harvard.edu> writes:

> The "short write" error reported by http.pm is a shorthand for
> "Your operating system has exploited a perfectly legal feature
> that apparently has not been encountered in other operating
> systems to date."

It is also shorthand for "Gisle is lazy" :-)

> That feature is the possibility that syswrite
> might return having only written part of the requested record,
> and I have encountered it under QNX4 for file sizes in excess
> of 10K bytes. This patch does the obvious loop to write out the
> rest.

Thanks.  There are two other places in http.pm that dies with "short
write".  Do you care enough to patch them all or did you decide that
the others where less likely to happen?

Regards,
Gisle


> *** ../ORIG/libwww-perl-5.53/lib/LWP/Protocol/http.pm	Fri Apr  6 22:13:25 2001
> --- libwww-perl-5.53/lib/LWP/Protocol/http.pm	Tue Aug  7 13:26:29 2001
> ***************
> *** 173,182 ****
>   	}
>       }
>       elsif (defined($$cont_ref) && length($$cont_ref)) {
> ! 	die "write timeout" if $timeout && !$sel->can_write($timeout);
> ! 	$n = $socket->syswrite($$cont_ref, length($$cont_ref));
> ! 	die $! unless defined($n);
> ! 	die "short write" unless $n == length($$cont_ref);
>   	LWP::Debug::conns($buf);
>       }
>   
> --- 173,186 ----
>   	}
>       }
>       elsif (defined($$cont_ref) && length($$cont_ref)) {
> ! 	my $offset = 0;
> ! 	my $length = length($$cont_ref);
> ! 	while ( $offset < $length ) {
> ! 	    die "write timeout" if $timeout && !$sel->can_write($timeout);
> ! 	    $n = $socket->syswrite($$cont_ref, $length-$offset, $offset );
> ! 	    die $! unless defined($n);
> ! 	    $offset += $n;
> ! 	}
>   	LWP::Debug::conns($buf);
>       }
>   

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About