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.16 by root, Fri Nov 30 05:11:23 2001 UTC vs.
Revision 1.18 by root, Sat Dec 1 01:37:24 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 ], transfer::; 13 my $trans = bless [ $self ], transfer::;
14 Scalar::Util::weaken($trans->[0]);
15 14
16 push @{$self->{wait}}, $trans; 15 push @{$self->{wait}}, $trans;
17 Scalar::Util::weaken($self->{wait}[-1]); 16 Scalar::Util::weaken($self->{wait}[-1]);
18 17
19 --$self->{conns}; 18 if (--$self->{conns} >= 0) {
20 $self->wake_next; 19 $self->wake_next;
20 }
21 21
22 $trans; 22 $trans;
23} 23}
24 24
25sub wake_next { 25sub wake_next {
26 my $self = shift; 26 my $self = shift;
27 27
28 if ($self->{conns} >= 0) {
29 while(@{$self->{wait}}) { 28 while(@{$self->{wait}}) {
30 my $transfer = shift @{$self->{wait}}; 29 my $transfer = shift @{$self->{wait}};
31 if ($transfer) { 30 if ($transfer) {
32 $transfer->wake; 31 $transfer->wake;
33 last; 32 last;
34 }
35 } 33 }
36 } 34 }
37} 35}
38 36
39sub waiters { 37sub waiters {
53sub try { 51sub try {
54 my $self = shift; 52 my $self = shift;
55 53
56 unless ($self->[2]) { 54 unless ($self->[2]) {
57 my $timeout = Coro::Timer::timeout $_[0]; 55 my $timeout = Coro::Timer::timeout $_[0];
58 $self->[1] = $Coro::current; 56 local $self->[1] = $Coro::current;
59 57
60 Coro::schedule; 58 Coro::schedule;
61
62 undef $self->[1];
63 } 59 }
64 60
65 return $self->[2]; 61 return $self->[2];
66} 62}
67 63
68sub DESTROY { 64sub DESTROY {
69 my $self = shift; 65 my $self = shift;
70 $self->[0]{conns}++; 66 $self->[0]{conns}++;
71 $self->[0]->wake_next; 67 $self->[0]->wake_next if $self->[2];
72} 68}
73 69
74package conn; 70package conn;
75 71
76our %blockuri; 72our %blockuri;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines