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

Comparing Coro/myhttpd/access.pl (file contents):
Revision 1.12 by root, Thu Nov 29 01:53:40 2001 UTC vs.
Revision 1.14 by root, Fri Nov 30 03:02:23 2001 UTC

12 12
13 my $trans = bless [ $self, $Coro::current ], transfer::; 13 my $trans = bless [ $self, $Coro::current ], transfer::;
14 Scalar::Util::weaken($trans->[0]); 14 Scalar::Util::weaken($trans->[0]);
15 15
16 push @{$self->{wait}}, $trans; 16 push @{$self->{wait}}, $trans;
17 Scalar::Util::weaken($self->{wait}[-1]);
17 18
18 if (--$self->{conns} >= 0) { 19 if (--$self->{conns} >= 0) {
19 $self->wake_next; 20 $self->wake_next;
20 } 21 }
21 22
23} 24}
24 25
25sub wake_next { 26sub wake_next {
26 my $self = shift; 27 my $self = shift;
27 28
28 return unless $self->{conns} >= 0; 29 if ($self->{conns} >= 0) {
29 30 while(@{$self->{wait}}) {
30 (pop @{$self->{wait}})->wake if @{$self->{wait}}; 31 my $transfer = shift @{$self->{wait}};
32 if ($transfer) {
33 $transfer->wake;
34 last;
35 }
36 }
37 }
31} 38}
32 39
33sub waiters { 40sub waiters {
34 map $_->[1], @{$_[0]{wait}}; 41 map $_->[1], @{$_[0]{wait}};
35} 42}
40 47
41sub try { 48sub try {
42 my $self = shift; 49 my $self = shift;
43 my $timeout = Coro::Timer::timeout $_[0]; 50 my $timeout = Coro::Timer::timeout $_[0];
44 51
45 Coro::schedule; 52 $self->[2] or Coro::schedule;
46 53
47 return $self->[2]; 54 return $self->[2];
48} 55}
49 56
50sub wake { 57sub wake {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines