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

Comparing Coro/myhttpd/tbf.pl (file contents):
Revision 1.1 by root, Sun May 19 21:00:48 2002 UTC vs.
Revision 1.2 by root, Mon May 20 04:08:04 2002 UTC

49 } 49 }
50 } 50 }
51 51
52 } else { 52 } else {
53 if ($self->{maxbucket} < $self->{bucket}) { 53 if ($self->{maxbucket} < $self->{bucket}) {
54 ::slog (9, "unused bandwith: ".($self->{bucket} - $self->{maxbucket}));#d# 54 ::unused_bandwidth ($self->{bucket} - $self->{maxbucket});
55 $self->{bucket} = $self->{maxbucket}; 55 $self->{bucket} = $self->{maxbucket};
56 } 56 }
57 } 57 }
58 58
59 last; 59 last;
65sub request { 65sub request {
66 my ($self, $bytes, $weight) = @_; 66 my ($self, $bytes, $weight) = @_;
67 67
68 $weight ||= 1; 68 $weight ||= 1;
69 69
70 if ($self->{waitw} || $self->{bucket} < $bytes || 1) {
71 my $coro = $Coro::current; 70 my $coro = $Coro::current;
72 my $id = $_tbf_id++; 71 my $id = $_tbf_id++;
73 72
74 $self->{waitw} += $weight; 73 $self->{waitw} += $weight;
75 $self->{waitq}{$id} = [$weight, 0, $bytes, sub { 74 $self->{waitq}{$id} = [$weight, 0, $bytes, sub {
76 delete $self->{waitq}{$id}; 75 delete $self->{waitq}{$id};
77 $self->{waitw} -= $weight; 76 $self->{waitw} -= $weight;
78 $coro->ready; 77 $coro->ready;
79 }]; 78 }];
80 79
81 Coro::schedule; 80 Coro::schedule;
82 } else {
83 $self->{bucket} -= $bytes;
84 }
85} 81}
86 82
871; 831;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines