logo       

LWP::Protocol:http does not check for temporary errors during upload: msg#00006

Subject: LWP::Protocol:http does not check for temporary errors during upload
I had much difficulty in attempting to use 'trickle', a bandwidth
constraining utility, to limit the upload speed of flickr_upload,
which uses the Flickr::API modules, which in turn use
LWP::Protocol::http. An error response from LWP::Protocol::http was
being propogated back upward and causing the upload to abort.

I traced the problem to this segment of code in LWP/Protocol/http.pm:

            if (defined($wbits) && $wbits =~ /[^\0]/) {
                my $n = $socket->syswrite($$wbuf, length($$wbuf), $woffset);
                unless ($n) {
                    die "syswrite: $!" unless defined $n;
                    die "syswrite: no bytes written";
                }
                $woffset += $n;

After the syswrite, the error response is not checked for a temporary
error like "Resource temporarily unavailable" and just fails outright.
I modified the code in my personal copy to:
  - retry if the error response is "Resource temporarily unavailable"
  - make smaller writes (makes for smoother rate shaping with 'trickle')
  - use Time::HiRes and sleep for a short period of time between attempts

            if (defined($wbits) && $wbits =~ /[^\0]/) {
                my $n;
                do {
                    $n = $socket->syswrite($$wbuf, 2048, $woffset);
                } while ($! eq 'Resource temporarily unavailable' &&
sleep(0.005));
                unless ($n) {
                    die "syswrite: $!" unless defined $n;
                    die "syswrite: no bytes written";
                }
                $woffset += $n;

That's probably not the most ideal general-purpose remedy, but it
worked great in getting it to not fail outright when run with trickle.

In any case, I thought I would point out this problem so that it could
perhaps be addressed in a future release of LWP.

   Thanks!
   -jrs



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
audio.irate.dev...    yellowdog.gener...    ietf.ips/2002-0...    xfree86.fonts/2...    busybox/2003-07...    emacs.jdee/2004...    linux.mandrake....    hardware.microc...    user-groups.lin...    science.analysi...    version-control...    db.filemaker.de...    cluster.openmos...    mail.eyebrowse....    text.xml.xerces...    kde.devel.kwrit...    finance.moneyda...    gcc.regression/...    network.routing...    os.freebsd.deve...    recreation.radi...    qnx.openqnx.dev...    python.xml/2002...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe