/[pxelator]/lib/PXElator/httpd.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /lib/PXElator/httpd.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 96 by dpavlin, Fri Jul 31 20:45:09 2009 UTC revision 104 by dpavlin, Fri Jul 31 22:52:22 2009 UTC
# Line 39  our $url = "http://$server::ip:$port"; Line 39  our $url = "http://$server::ip:$port";
39  use html;  use html;
40  our $static_pids;  our $static_pids;
41    
42    use Time::HiRes qw/time/;
43    
44  sub static {  sub static {
45          my ($client,$path) = @_;          my ($client,$path) = @_;
46    
# Line 46  sub static { Line 48  sub static {
48    
49          return if ! -f $full;          return if ! -f $full;
50    
51            my $start_t = time();
52    
53          if ( my $pid = fork ) {          if ( my $pid = fork ) {
54                  # parent                  # parent
55                  close($client);                  close($client);
# Line 76  sub static { Line 80  sub static {
80          while( my $len = read $fh, $buff, $block ) {          while( my $len = read $fh, $buff, $block ) {
81                  print $client $buff;                  print $client $buff;
82                  $pos += $len;                  $pos += $len;
83                  printf "%s %d/%d %.2f%%\r", $path, $pos, $size, $pos * 100 / $size;                  printf "%s %d/%d %.2f%% %.2f K/s\r"
84                            , $path, $pos
85                            , $size, $pos * 100 / $size
86                            , ( $pos / 1024 ) / ( time() - $start_t )
87                            ;
88          }          }
89          close($fh);          close($fh);
90          close($client);          close($client);

Legend:
Removed from v.96  
changed lines
  Added in v.104

  ViewVC Help
Powered by ViewVC 1.1.26