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.17 by root, Sat Dec 1 01:09:56 2001 UTC vs.
Revision 1.18 by root, Sat Dec 1 01:37:24 2001 UTC

13 my $trans = bless [ $self ], transfer::; 13 my $trans = bless [ $self ], transfer::;
14 14
15 push @{$self->{wait}}, $trans; 15 push @{$self->{wait}}, $trans;
16 Scalar::Util::weaken($self->{wait}[-1]); 16 Scalar::Util::weaken($self->{wait}[-1]);
17 17
18 print "ALLOC $Coro::current\n";#d# 18 if (--$self->{conns} >= 0) {
19 --$self->{conns};
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 while ($self->{conns} >= 0 && @{$self->{wait}}) {
29 print "WAKING some\n";#d#
30 while(@{$self->{wait}}) { 28 while(@{$self->{wait}}) {
31 my $transfer = shift @{$self->{wait}}; 29 my $transfer = shift @{$self->{wait}};
32 if ($transfer) { 30 if ($transfer) {
33 print "WAKING $transfer\n";#d#
34 $transfer->wake; 31 $transfer->wake;
35 last; 32 last;
36 }
37 } 33 }
38 } 34 }
39} 35}
40 36
41sub waiters { 37sub waiters {
58 unless ($self->[2]) { 54 unless ($self->[2]) {
59 my $timeout = Coro::Timer::timeout $_[0]; 55 my $timeout = Coro::Timer::timeout $_[0];
60 local $self->[1] = $Coro::current; 56 local $self->[1] = $Coro::current;
61 57
62 Coro::schedule; 58 Coro::schedule;
63 print "WOKE $Coro::current\n" if $self->[2];
64 } 59 }
65 60
66 return $self->[2]; 61 return $self->[2];
67} 62}
68 63
69sub DESTROY { 64sub DESTROY {
70 my $self = shift; 65 my $self = shift;
71 eval {
72 $self->[0]{conns}++; 66 $self->[0]{conns}++;
73 $self->[0]->wake_next; 67 $self->[0]->wake_next if $self->[2];
74 };
75 print "DESTROY $Coro::current $@\n";#d#
76} 68}
77 69
78package conn; 70package conn;
79 71
80our %blockuri; 72our %blockuri;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines