--- lib/PXElator/httpd.pm 2009/07/31 23:22:05 105 +++ lib/PXElator/httpd.pm 2009/08/02 12:09:02 115 @@ -38,8 +38,7 @@ use html; our $static_pids; - -use Time::HiRes qw/time/; +use progress_bar; sub static { my ($client,$path) = @_; @@ -71,33 +70,24 @@ my $buff; my $pos = 0; - STDERR->autoflush(1); warn "static $path $type $size block: $block\n"; - my $start_t = time(); - my $last_t = $start_t; + progress_bar::start; while( my $len = read $fh, $buff, $block ) { - syswrite $client,$buff; + print $client $buff; $client->flush; $pos += $len; - my $t = time(); - next unless $t - $last_t > 0.75; - $last_t = $t; - my $speed = ( $pos ) / ( $t - $start_t ); - printf STDERR "%s %d/%d %.2f%% %.2f K/s ETA %.1fs\r" - , $path, $pos - , $size, $pos * 100 / $size - , $speed / 1024 - , ( $size - $pos ) / $speed - ; + progress_bar::tick( $path, $pos, $size ); } close($fh); close($client); print STDERR "\n"; - exit; + warn "exit static child"; + + exit(0); } use boolean;