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.18 by root, Wed Aug 15 03:13:36 2001 UTC vs.
Revision 1.19 by root, Thu Aug 16 16:40:07 2001 UTC

121sub DESTROY { 121sub DESTROY {
122 my $self = shift; 122 my $self = shift;
123 123
124 $::conns--; 124 $::conns--;
125 125
126 $self->eoconn;
126 delete $conn{$self->{remote_addr}}{$self*1}; 127 delete $conn{$self->{remote_addr}}{$self*1};
128}
129
130# end of connection
131sub eoconn {
127 delete $uri{$self->{remote_addr}}{$self->{uri}}{$self*1}; 132 delete $uri{$self->{remote_addr}}{$self->{uri}}{$self*1};
128} 133}
129 134
130sub slog { 135sub slog {
131 my $self = shift; 136 my $self = shift;
267 weaken ($uri{$self->{remote_addr}}{$self->{uri}}{$self*1} = $self); 272 weaken ($uri{$self->{remote_addr}}{$self->{uri}}{$self*1} = $self);
268 273
269 $self->map_uri; 274 $self->map_uri;
270 $self->respond; 275 $self->respond;
271 276
277 $self->eoconn;
278
272 last if $self->{h}{connection} =~ /close/ || $self->{version} lt "1.1"; 279 last if $self->{h}{connection} =~ /close/ || $self->{version} lt "1.1";
273 280
274 $self->slog(9, "persistant connection [".$self->{h}{"user-agent"}."][$self->{reqs}]"); 281 $self->slog(9, "persistent connection [".$self->{h}{"user-agent"}."][$self->{reqs}]");
275 $fh->timeout($::PER_TIMEOUT); 282 $fh->timeout($::PER_TIMEOUT);
276 } 283 }
277} 284}
278 285
279# uri => path mapping 286# uri => path mapping
455 open $fh, "<", $self->{path} 462 open $fh, "<", $self->{path}
456 or die "$self->{path}: late open failure ($!)"; 463 or die "$self->{path}: late open failure ($!)";
457 464
458 $h -= $l - 1; 465 $h -= $l - 1;
459 466
467 if (0) {
468 if ($l) {
469 sysseek $fh, $l, 0;
470 }
471 }
472
460 while ($h > 0) { 473 while ($h > 0) {
474 if (0) {
475 sysread $fh, $buf, $h > $::BUFSIZE ? $::BUFSIZE : $h
476 or last;
477 } else {
461 aio_read($fh, $l, ($h > $::BUFSIZE ? $::BUFSIZE : $h), 478 aio_read($fh, $l, ($h > $::BUFSIZE ? $::BUFSIZE : $h),
462 $buf, 0, sub { 479 $buf, 0, sub {
463 $r = $_[0]; 480 $r = $_[0];
464 $current->ready; 481 $current->ready;
465 }); 482 });
466 &Coro::schedule; 483 &Coro::schedule;
467 last unless $r; 484 last unless $r;
485 }
468 my $w = $self->{fh}->syswrite($buf) 486 my $w = $self->{fh}->syswrite($buf)
469 or last; 487 or last;
470 $::written += $w; 488 $::written += $w;
471 $self->{written} += $w; 489 $self->{written} += $w;
472 $l += $r; 490 $l += $r;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines