--- lib/PXElator/httpd.pm 2009/08/01 00:44:52 107 +++ lib/PXElator/httpd.pm 2009/08/03 08:52:32 118 @@ -17,7 +17,6 @@ use File::Slurp; #use JSON; use IO::Socket::INET; -use Module::Refresh; our $pids; $pids = { httpd => $$ } unless defined $pids; # keep pids on refresh @@ -38,8 +37,7 @@ use html; our $static_pids; - -use Time::HiRes qw/time/; +use progress_bar; sub static { my ($client,$path) = @_; @@ -71,26 +69,15 @@ 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 ) { 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); @@ -269,14 +256,12 @@ start_stop 'screen'; start_stop 'kvm'; - while (my $client = $server->accept()) { - $client->autoflush(1); + while (1) { + my $client = $server->accept() || next; # ALARM trickle us my $request = <$client>; warn "request $request\n" if $debug; - Module::Refresh->refresh; - if ($request =~ m{^GET (/.*) HTTP/1.[01]}) { my $path = $1; my $param;