ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/myhttpd/httpd.pl
(Generate patch)

Comparing Coro/myhttpd/httpd.pl (file contents):
Revision 1.79 by root, Fri Dec 1 03:53:33 2006 UTC vs.
Revision 1.80 by root, Fri Dec 1 04:18:32 2006 UTC

22our $accesslog; 22our $accesslog;
23our $errorlog; 23our $errorlog;
24 24
25our $NOW; 25our $NOW;
26our $HTTP_NOW; 26our $HTTP_NOW;
27
28our $ERROR_LOG;
29our $ACCESS_LOG;
27 30
28Event->timer(interval => 1, hard => 1, cb => sub { 31Event->timer(interval => 1, hard => 1, cb => sub {
29 $NOW = time; 32 $NOW = time;
30 $HTTP_NOW = time2str $NOW; 33 $HTTP_NOW = time2str $NOW;
31})->now; 34})->now;
137 listen_on $http_port; 140 listen_on $http_port;
138} 141}
139 142
140package conn; 143package conn;
141 144
145use strict;
146use bytes;
147
142use Socket; 148use Socket;
143use HTTP::Date; 149use HTTP::Date;
144use Convert::Scalar 'weaken'; 150use Convert::Scalar 'weaken';
145use IO::AIO; 151use IO::AIO;
146 152
202 for (keys %$hash) { 208 for (keys %$hash) {
203 if (ref $hash->{$_} eq HASH::) { 209 if (ref $hash->{$_} eq HASH::) {
204 prune_cache($hash->{$_}); 210 prune_cache($hash->{$_});
205 unless (scalar keys %{$hash->{$_}}) { 211 unless (scalar keys %{$hash->{$_}}) {
206 delete $hash->{$_}; 212 delete $hash->{$_};
207 $d2++;
208 } 213 }
209 } 214 }
210 } 215 }
211} 216}
212 217
597 602
598 if ($self->{method} eq "GET") { 603 if ($self->{method} eq "GET") {
599 $self->{time} = $::NOW; 604 $self->{time} = $::NOW;
600 $self->{written} = 0; 605 $self->{written} = 0;
601 606
602 my $current = $Coro::current; 607 my $fh;
603
604 my ($fh, $buf, $r);
605 608
606 open $fh, "<", $self->{path} 609 open $fh, "<", $self->{path}
607 or die "$self->{path}: late open failure ($!)"; 610 or die "$self->{path}: late open failure ($!)";
608 611
609 $h -= $l - 1; 612 $h -= $l - 1;
630 if ($blocked{$self->{remote_id}}) { 633 if ($blocked{$self->{remote_id}}) {
631 $self->{h}{connection} = "close"; 634 $self->{h}{connection} = "close";
632 die bless {}, err::; 635 die bless {}, err::;
633 } 636 }
634 637
635 Coro::AIO::aio_read $fh, $l, ($h > $bufsize ? $bufsize : $h), $buf, 0 638 Coro::AIO::aio_read $fh, $l, ($h > $bufsize ? $bufsize : $h), my $buf, 0
636 or last; 639 or last;
637 640
638 $tbf->request (length $buf); 641 $tbf->request (length $buf);
639 my $w = syswrite $self->{fh}, $buf 642 my $w = syswrite $self->{fh}, $buf
640 or last; 643 or last;
641 $::written += $w; 644 $::written += $w;
642 $self->{written} += $w; 645 $self->{written} += $w;
643 $l += $r; 646 $l += $w;
644 } 647 }
645 648
646 close $fh; 649 close $fh;
647 } 650 }
648} 651}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines