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

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

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines