--- apt-cacher.orig 2008-10-18 22:31:58.000000000 +0100 +++ apt-cacher 2008-10-18 23:01:46.000000000 +0100 @@ -238,7 +238,8 @@ my $notify_file; my $do_import=0; -my $concloseflag; +my $concloseflag=0; +my $respbeensent=0; my $ua; my $daemon; @@ -552,14 +553,17 @@ my $rangereq; REQUEST: - while(!$concloseflag) { + while(!($concloseflag && $respbeensent)) { - debug_message("Processing a new request line"); + debug_message("Processing a new request line" . $concloseflag . " " . $respbeensent); $_=&getRequestLine; debug_message("got: $_"); - exit if !defined($_); + if (!defined($_)){ + #this is to attempt to send a response + $concloseflag=1; + }; if(/^$/) { if(defined($testpath)) { @@ -578,6 +582,9 @@ else { if(/^(GET|HEAD)\s+(\S+)/) { + #We have a request which still needs a response... + $respbeensent=0; + if(defined($testpath)) { &sendrsp(403, "Confusing request"); exit(4); @@ -596,9 +603,11 @@ } elsif(/^Connection: close/i) { $concloseflag=1; + debug_message("Connection close found: $concloseflag"); } elsif(/^Connection: .*TE/) { $concloseflag=1; + debug_message("Connection flag found: $concloseflag"); } elsif(/^Range/i) { $rangereq=1; @@ -850,6 +859,7 @@ &return_file (\$fromfile, $send_head_only); debug_message("Package sent"); + $respbeensent=1; # Write all the stuff to the log file writeaccesslog("$cache_status", "$new_filename"); @@ -1503,6 +1513,8 @@ $initmsg.="Connection: Keep-Alive\r\nAccept-Ranges: bytes\r\nKeep-Alive: timeout=15, max=100\r\n" if ($code ne 403); + $respbeensent=1; + debug_message("Sending Response...: respbeensent=$respbeensent"); #debug_message("Sending Response: $initmsg"); print $con $initmsg;