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.21 by root, Fri Aug 17 03:33:00 2001 UTC vs.
Revision 1.24 by root, Sat Aug 18 13:32:17 2001 UTC

77Linux::AIO::min_parallel $::AIO_PARALLEL; 77Linux::AIO::min_parallel $::AIO_PARALLEL;
78 78
79Event->io(fd => Linux::AIO::poll_fileno, 79Event->io(fd => Linux::AIO::poll_fileno,
80 poll => 'r', async => 1, 80 poll => 'r', async => 1,
81 cb => \&Linux::AIO::poll_cb); 81 cb => \&Linux::AIO::poll_cb);
82my $scheduler = Event->idle(
83 max => 0, min => 0, prio => 6, parked => 1,
84 cb => \&Coro::schedule);
85 82
86our %conn; # $conn{ip}{fh} => connobj 83our %conn; # $conn{ip}{fh} => connobj
87our %blocked; 84our %blocked;
88our %mimetype; 85our %mimetype;
89 86
274 271
275 $self->{server_port} = $self->{h}{host} =~ s/:([0-9]+)$// ? $1 : 80; 272 $self->{server_port} = $self->{h}{host} =~ s/:([0-9]+)$// ? $1 : 80;
276 273
277 weaken ($uri{$self->{remote_addr}}{$self->{uri}}{$self*1} = $self); 274 weaken ($uri{$self->{remote_addr}}{$self->{uri}}{$self*1} = $self);
278 275
276 eval {
279 $self->map_uri; 277 $self->map_uri;
280 $self->respond; 278 $self->respond;
279 };
280
281 die if $@ && !ref $@;
281 282
282 $self->eoconn; 283 $self->eoconn;
283 284
284 last if $self->{h}{connection} =~ /close/ || $self->{version} lt "1.1"; 285 last if $self->{h}{connection} =~ /close/ || $self->{version} lt "1.1";
285 286
432 goto ignore; 433 goto ignore;
433 } 434 }
434 goto satisfiable if $l >= 0 && $l < $length && $h >= 0 && $h > $l; 435 goto satisfiable if $l >= 0 && $l < $length && $h >= 0 && $h > $l;
435 } 436 }
436 $hdr->{"Content-Range"} = "bytes */$length"; 437 $hdr->{"Content-Range"} = "bytes */$length";
438 $hdr->{"Content-Length"} = $length;
437 $self->slog(9, "not satisfiable($self->{h}{range}|".$self->{h}{"user-agent"}.")"); 439 $self->slog(9, "not satisfiable($self->{h}{range}|".$self->{h}{"user-agent"}.")");
438 $self->err(416, "not satisfiable", $hdr); 440 $self->err(416, "not satisfiable", $hdr, "");
439 441
440satisfiable: 442satisfiable:
441 # check for segmented downloads 443 # check for segmented downloads
442 if ($l && $::NO_SEGMENTED) { 444 if ($l && $::NO_SEGMENTED) {
443 if (%{$uri{$self->{remote_addr}}{$self->{uri}}} > 1) { 445 if (%{$uri{$self->{remote_addr}}{$self->{uri}}} > 1) {
483 } else { 485 } else {
484 aio_read($fh, $l, ($h > $::BUFSIZE ? $::BUFSIZE : $h), 486 aio_read($fh, $l, ($h > $::BUFSIZE ? $::BUFSIZE : $h),
485 $buf, 0, sub { 487 $buf, 0, sub {
486 $r = $_[0]; 488 $r = $_[0];
487 $current->ready; 489 $current->ready;
488 $scheduler->now;
489 }); 490 });
490 &Coro::schedule; 491 &Coro::schedule;
491 last unless $r; 492 last unless $r;
492 } 493 }
493 my $w = $self->{fh}->syswrite($buf) 494 my $w = $self->{fh}->syswrite($buf)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines