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.34 by root, Thu Aug 30 02:58:17 2001 UTC vs.
Revision 1.35 by root, Thu Aug 30 12:35:28 2001 UTC

32our $connections = new Coro::Semaphore $MAX_CONNECTS || 250; 32our $connections = new Coro::Semaphore $MAX_CONNECTS || 250;
33 33
34our $wait_factor = 0.95; 34our $wait_factor = 0.95;
35 35
36our @transfers = ( 36our @transfers = (
37 [(new Coro::Semaphore $MAX_TRANSFERS_SMALL || 50), 600], 37 [(new Coro::Semaphore $MAX_TRANSFERS_SMALL || 50), 1],
38 [(new Coro::Semaphore $MAX_TRANSFERS_LARGE || 50), 600], 38 [(new Coro::Semaphore $MAX_TRANSFERS_LARGE || 50), 1],
39); 39);
40 40
41my @newcons; 41my @newcons;
42my @pool; 42my @pool;
43 43
193sub err { 193sub err {
194 my $self = shift; 194 my $self = shift;
195 my ($code, $msg, $hdr, $content) = @_; 195 my ($code, $msg, $hdr, $content) = @_;
196 196
197 unless (defined $content) { 197 unless (defined $content) {
198 $content = "$code $msg"; 198 $content = "$code $msg\n";
199 $hdr->{"Content-Type"} = "text/plain"; 199 $hdr->{"Content-Type"} = "text/plain";
200 $hdr->{"Content-Length"} = length $content; 200 $hdr->{"Content-Length"} = length $content;
201 } 201 }
202 $hdr->{"Connection"} = "close"; 202 $hdr->{"Connection"} = "close";
203 203
452 } 452 }
453 goto satisfiable if $l >= 0 && $l < $length && $h >= 0 && $h >= $l; 453 goto satisfiable if $l >= 0 && $l < $length && $h >= 0 && $h >= $l;
454 } 454 }
455 $hdr->{"Content-Range"} = "bytes */$length"; 455 $hdr->{"Content-Range"} = "bytes */$length";
456 $hdr->{"Content-Length"} = $length; 456 $hdr->{"Content-Length"} = $length;
457 $self->slog(9, "not satisfiable($self->{h}{range}|".$self->{h}{"user-agent"}.")");
458 $self->err(416, "not satisfiable", $hdr, ""); 457 $self->err(416, "not satisfiable", $hdr, "");
459 458
460satisfiable: 459satisfiable:
461 # check for segmented downloads 460 # check for segmented downloads
462 if ($l && $::NO_SEGMENTED) { 461 if ($l && $::NO_SEGMENTED) {
486 $self->response(@code, $hdr, ""); 485 $self->response(@code, $hdr, "");
487 486
488 if ($self->{method} eq "GET") { 487 if ($self->{method} eq "GET") {
489 $self->{time} = $::NOW; 488 $self->{time} = $::NOW;
490 489
490 my $fudge = $queue->[0]->waiters;
491 $fudge = $fudge ? ($fudge+1)/$fudge : 1;
492
493 $queue->[1] *= $fudge;
491 my $transfer = $queue->[0]->guard; 494 my $transfer = $queue->[0]->guard;
495
496 if ($fudge != 1) {
497 $queue->[1] /= $fudge;
498 $queue->[1] = $queue->[1] * $::wait_factor
499 + ($::NOW - $self->{time}) * (1 - $::wait_factor);
500 }
501 $self->{time} = $::NOW;
502
492 $self->{fh}->writable or return; 503 $self->{fh}->writable or return;
493
494 $queue->[1] = $queue->[1] * $::wait_factor
495 + ($::NOW - $self->{time}) * (1 - $::wait_factor);
496 $self->{time} = $::NOW;
497 504
498 my ($fh, $buf, $r); 505 my ($fh, $buf, $r);
499 my $current = $Coro::current; 506 my $current = $Coro::current;
500 open $fh, "<", $self->{path} 507 open $fh, "<", $self->{path}
501 or die "$self->{path}: late open failure ($!)"; 508 or die "$self->{path}: late open failure ($!)";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines