/[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 91 by dpavlin, Fri Jul 31 18:48:29 2009 UTC revision 96 by dpavlin, Fri Jul 31 20:45:09 2009 UTC
# Line 61  sub static { Line 61  sub static {
61    
62          my $size = -s $full || return;          my $size = -s $full || return;
63    
64            $client->autoflush(1);
65    
66          print $client "HTTP/1.0 200 OK\r\nContent-Type: $type\r\nContent-Length: $size\r\nConnection: close\r\n\r\n";          print $client "HTTP/1.0 200 OK\r\nContent-Type: $type\r\nContent-Length: $size\r\nConnection: close\r\n\r\n";
67    
68          open(my $fh, $full);          open(my $fh, $full);
         print "static $path $type $size\n";  
69    
70          my $block = 8192;          my $block = 1400; # try not to fragment packages (pxelinux seems to have problems with it)
71          my $buff;          my $buff;
72          my $pos = 0;          my $pos = 0;
73    
74            print "static $path $type $size block: $block\n";
75    
76          while( my $len = read $fh, $buff, $block ) {          while( my $len = read $fh, $buff, $block ) {
77                  print $client $buff;                  print $client $buff;
78                  $pos += $len;                  $pos += $len;
# Line 78  sub static { Line 81  sub static {
81          close($fh);          close($fh);
82          close($client);          close($client);
83    
84          print "$path $pos == $size OK\n";          print "\n";
85    
86          exit;          exit;
87  }  }
# Line 94  sub start_stop { Line 97  sub start_stop {
97          my $daemon = shift;          my $daemon = shift;
98          my $pid = $pids->{$daemon};          my $pid = $pids->{$daemon};
99    
100          warn "start_stop $daemon $pid pids: ",dump( $pids );          warn "start_stop $daemon $pid\n";
101    
102          if ( $pid =~ m{^\d+$} ) {          if ( $pid =~ m{^\d+$} ) {
103                  my $pstree = `pstree -p $pid`;                  my $pstree = `pstree -p $pid`;
# Line 107  sub start_stop { Line 110  sub start_stop {
110                  if ( $pid = fork ) {                  if ( $pid = fork ) {
111                          # parent                          # parent
112                          $pids->{$daemon} = $pid;                          $pids->{$daemon} = $pid;
113                          warn "forked $daemon $pid";                          warn "forked $daemon $pid\n";
114                          return qq|$daemon pid $pid started|;                          return qq|$daemon pid $pid started|;
115                  } elsif ( defined $pid ) {                  } elsif ( defined $pid ) {
116                          # child                          # child
# Line 130  my $redirect = qq|HTTP/1.1 302 Found\r\n Line 133  my $redirect = qq|HTTP/1.1 302 Found\r\n
133  sub get_request {  sub get_request {
134          my ( $client, $path, $param ) = @_;          my ( $client, $path, $param ) = @_;
135    
136          warn "get_request $client $path ",dump( $param );          warn "get_request $path ", $param ? dump( $param ) : '', "\n";
137    
138          if ( my $found = static( $client,$path ) ) {          if ( my $found = static( $client,$path ) ) {
139                  warn "static $found" if $debug;                  warn "static $found" if $debug;
# Line 147  sub get_request { Line 150  sub get_request {
150                          'debug',        qq|<a href=/our/debug/| . boolean::toggle($debug) . qq|>$debug</a>|,                          'debug',        qq|<a href=/our/debug/| . boolean::toggle($debug) . qq|>$debug</a>|,
151                  );                  );
152    
153                  my $debug_proc;                  my $debug_proc = '';
154    
155                  warn 'pids: ', dump( $pids ) if $debug;                  warn 'pids: ', dump( $pids ) if $debug;
156                  foreach my $name ( sort keys %$pids ) {                  foreach my $name ( sort keys %$pids ) {
# Line 268  sub start { Line 271  sub start {
271                                  }                                  }
272                                  warn "param: ",dump( $param ) if $debug;                                  warn "param: ",dump( $param ) if $debug;
273                          }                          }
                         warn "path $path param: ",dump( $param );  
274                          get_request $client, $path, $param;                          get_request $client, $path, $param;
275                  } else {                  } else {
276                          print $client "HTTP/1.0 500 No method\r\nConnection: close\r\nContent-type: text/plain\r\n\r\n500 $request";                          print $client "HTTP/1.0 500 No method\r\nConnection: close\r\nContent-type: text/plain\r\n\r\n500 $request";

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

  ViewVC Help
Powered by ViewVC 1.1.26