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

Comparing cvsroot/Coro/myhttpd/httpd.pl (file contents):
Revision 1.83 by root, Sun Dec 3 17:49:22 2006 UTC vs.
Revision 1.84 by root, Sat Dec 8 21:01:16 2007 UTC

1use Coro; 1use Coro;
2use Coro::Semaphore; 2use Coro::Semaphore;
3use Coro::Event; 3use Coro::EV;
4use Coro::Socket; 4use Coro::Socket;
5use Coro::Signal; 5use Coro::Signal;
6use Coro::AIO (); 6use Coro::AIO ();
7 7
8use HTTP::Date; 8use HTTP::Date;
26our $HTTP_NOW; 26our $HTTP_NOW;
27 27
28our $ERROR_LOG; 28our $ERROR_LOG;
29our $ACCESS_LOG; 29our $ACCESS_LOG;
30 30
31Event->timer(interval => 1, hard => 1, cb => sub { 31our $update_time = EV::periodic 0, 1, undef, sub {
32 $NOW = time; 32 $NOW = time;
33 $HTTP_NOW = time2str $NOW; 33 $HTTP_NOW = time2str $NOW;
34})->now; 34};
35$update_time->invoke;
35 36
36if ($ERROR_LOG) { 37if ($ERROR_LOG) {
37 use IO::Handle; 38 use IO::Handle;
38 open $errorlog, ">>$ERROR_LOG" 39 open $errorlog, ">>$ERROR_LOG"
39 or die "$ERROR_LOG: $!"; 40 or die "$ERROR_LOG: $!";
150use Convert::Scalar 'weaken'; 151use Convert::Scalar 'weaken';
151use IO::AIO; 152use IO::AIO;
152 153
153IO::AIO::min_parallel $::AIO_PARALLEL; 154IO::AIO::min_parallel $::AIO_PARALLEL;
154 155
155Event->io (fd => IO::AIO::poll_fileno, 156our $AIO_WATCHER = EV::io IO::AIO::poll_fileno, EV::READ, \&IO::AIO::poll_cb;
156 poll => 'r', async => 1,
157 cb => \&IO::AIO::poll_cb);
158 157
159our %conn; # $conn{ip}{self} => connobj 158our %conn; # $conn{ip}{self} => connobj
160our %uri; # $uri{ip}{uri}{self} 159our %uri; # $uri{ip}{uri}{self}
161our %blocked; 160our %blocked;
162our %mimetype; 161our %mimetype;
222 for (keys %blocked) { 221 for (keys %blocked) {
223 delete $blocked{$_} unless $blocked{$_}[0] > $::NOW; 222 delete $blocked{$_} unless $blocked{$_}[0] > $::NOW;
224 } 223 }
225} 224}
226 225
227Event->timer (interval => 60, cb => \&prune_caches); 226our $PRUNE_WATCHER = EV::timer 60, 60, \&prune_caches;
228 227
229sub slog { 228sub slog {
230 my $self = shift; 229 my $self = shift;
231 main::slog($_[0], "$self->{remote_id}> $_[1]"); 230 main::slog($_[0], "$self->{remote_id}> $_[1]");
232} 231}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines