tag 349745 patch moreinfo
thanks

Nigel Horne <[EMAIL PROTECTED]> writes:

[...]
> njh:/var/log/squid# /usr/sbin/squid-prefetch
> Alarm clock

It seems the alarm timer isn't getting reset in case of exceptions.
Does the attached patch work for you?

Thanks!

Matej
--- squid-prefetch~
+++ squid-prefetch
@@ -144,14 +144,18 @@
        local $SIG{ALRM} = sub { die "Error: Timeout fetching $url\n" };
        alarm(3);
 
+       eval {
        my $http = Net::HTTP->new(PeerHost => $ProxyHost, PeerPort => 
$ProxyPort, Host => $host, SendTE => 0, KeepAlive => 0);
        $http->write_request("GET" => "http://$host$path";, "Accept" => 
"text/html", "Cache-Control" => "only-if-cached", "User-Agent" => 
"Squid-Prefetch");
        my ($code,$mesg,%hdrs) = $http->read_response_headers();
        print "\nfetch: $url: $code ($mesg)\n";
        print "  $k  ->  $v\n" while (($k,$v) = each %hdrs);
+       };
 
        alarm(0);
 
+       die if $@;
+
        if ($code != 200) {
                print STDERR "Warning: fetch returned code $code ($mesg) for 
$url\n";
                return;
@@ -170,6 +174,7 @@
        }
 
        alarm(5);
+       eval {
        while (1) {
                my $bufr;
                my $size = $http->read_entity_body($bufr,4096);
@@ -193,7 +198,9 @@
 
                $data =~ s!^.*($|<)!!;
        }
+       };
        alarm(0);
+       die if $@;
 
        @links = uniq(sort(@links));
        RandomizeArray([EMAIL PROTECTED]);
@@ -216,14 +223,18 @@
        local $SIG{ALRM} = sub { die "Error: Timeout fetching $url\n" };
        alarm(3);
 
+       eval {
        my $http = Net::HTTP->new(PeerHost => $ProxyHost, PeerPort => 
$ProxyPort, Host => $host, SendTE => 1, KeepAlive => 0);
        $http->write_request("GET" => "http://$host$path";, "Accept" => 
"text/*", "User-Agent" => "Squid-Prefetch");
        my ($code,$mesg,%hdrs) = $http->read_response_headers();
        print "\nprefetch: $url: $code ($mesg)\n";
 #      print "  $k  ->  $v\n" while (($k,$v) = each %hdrs);
+       };
 
        alarm(0);
 
+       die if $@;
+
        if ($code != 200) {
                print STDERR "Warning: fetch returned code $code ($mesg) for 
$url\n";
                return;
@@ -238,6 +249,7 @@
        }
 
        alarm(5);
+       eval {
        while (1) {
                my $bufr;
                my $size = $http->read_entity_body($bufr,4096);
@@ -246,7 +258,9 @@
                $total += $size;
                last if ($total > $FetchMaxSize);
        }
+       };
        alarm(0);
+       die if $@;
 }
 
 

Reply via email to