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.67 by root, Sun May 19 21:00:47 2002 UTC vs.
Revision 1.71 by root, Mon Jul 29 21:41:54 2002 UTC

55our $httpevent = new Coro::Signal; 55our $httpevent = new Coro::Signal;
56 56
57our $queue_file = new transferqueue $MAX_TRANSFERS; 57our $queue_file = new transferqueue $MAX_TRANSFERS;
58our $queue_index = new transferqueue 10; 58our $queue_index = new transferqueue 10;
59 59
60our $tbf_top = new tbf rate => 200000; 60our $tbf_top = new tbf rate => 100000;
61
62my $unused_bytes = 0;
63my $unused_last = time;
64
65sub unused_bandwidth {
66 $unused_bytes += $_[0];
67 if ($unused_last < $NOW - 30 && $unused_bytes / ($NOW - $unused_last) > 50000) {
68 $unused_last = $NOW;
69 $unused_bytes = 0;
70 $queue_file->force_wake_next;
71 slog 1, "forced filetransfer due to unused bandwidth";
72 }
73}
61 74
62my @newcons; 75my @newcons;
63my @pool; 76my @pool;
64 77
65# one "execution thread" 78# one "execution thread"
219 $hdr->{"Content-Length"} = length $content; 232 $hdr->{"Content-Length"} = length $content;
220 $GZ = sprintf "GZ%02d", 100 - 100*((length $content) / $orig); 233 $GZ = sprintf "GZ%02d", 100 - 100*((length $content) / $orig);
221 } 234 }
222 235
223 $res .= "Date: $HTTP_NOW\015\012"; 236 $res .= "Date: $HTTP_NOW\015\012";
237 $res .= "Server: $::NAME\015\012";
224 238
225 while (my ($h, $v) = each %$hdr) { 239 while (my ($h, $v) = each %$hdr) {
226 $res .= "$h: $v\015\012" 240 $res .= "$h: $v\015\012"
227 } 241 }
228 $res .= "\015\012"; 242 $res .= "\015\012";
555 569
556 $self->response(@code, $hdr, ""); 570 $self->response(@code, $hdr, "");
557 571
558 if ($self->{method} eq "GET") { 572 if ($self->{method} eq "GET") {
559 $self->{time} = $::NOW; 573 $self->{time} = $::NOW;
574 $self->{written} = 0;
560 575
561 my $current = $Coro::current; 576 my $current = $Coro::current;
562 577
563 my ($fh, $buf, $r); 578 my ($fh, $buf, $r);
564 579
580 while ($h > 0) { 595 while ($h > 0) {
581 unless ($locked) { 596 unless ($locked) {
582 if ($locked ||= $transfer->try($::WAIT_INTERVAL)) { 597 if ($locked ||= $transfer->try($::WAIT_INTERVAL)) {
583 $bufsize = $::BUFSIZE; 598 $bufsize = $::BUFSIZE;
584 $self->{time} = $::NOW; 599 $self->{time} = $::NOW;
600 $self->{written} = 0;
585 } 601 }
586 } 602 }
587 603
588 if ($blocked{$self->{remote_id}}) { 604 if ($blocked{$self->{remote_id}}) {
589 $self->{h}{connection} = "close"; 605 $self->{h}{connection} = "close";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines