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.11 by root, Thu Nov 29 01:50:41 2001 UTC vs.
Revision 1.31 by root, Thu Nov 21 09:52:34 2002 UTC

1package transferqueue;
2
3sub new {
4 my $class = shift;
5 bless {
6 conns => $_[0],
7 }, $class;
8}
9
10sub start_transfer {
11 my $self = shift;
12
13 my $trans = bless [ $self, $Coro::current ], transfer::;
14 print "$self $trans $trans->[0] <<\n";#d#
15 Scalar::Util::weaken($trans->[0]);
16
17 push @{$self->{wait}}, $trans;
18
19 if (--$self->{conns} >= 0) {
20 $self->wake_next;
21 }
22
23 $trans;
24}
25
26sub wake_next {
27 my $self = shift;
28
29 return unless $self->{conns} >= 0;
30
31 (pop @{$self->{wait}})->wake if @{$self->{wait}};
32}
33
34sub waiters {
35 map $_->[1], @{$_[0]{wait}};
36}
37
38package transfer;
39
40use Coro::Timer ();
41
42sub try {
43 my $self = shift;
44 my $timeout = Coro::Timer::timeout $_[0];
45
46 Coro::schedule;
47
48 return $self->[2];
49}
50
51sub wake {
52 my $self = shift;
53 $self->[2] = 1;
54 $self->[1]->ready;
55}
56
57sub DESTROY {
58 my $self = shift;
59 $self->[0]{conns}++;
60 $self->[0]->wake_next;
61}
62
63package conn; 1package conn;
64 2
65our %blockuri; 3our %blockuri;
66our $blockref; 4our $blockref;
67 5
130 my %disallow; 68 my %disallow;
131 69
132 $self->err_block_referer 70 $self->err_block_referer
133 if $self->{h}{referer} =~ $blockref; 71 if $self->{h}{referer} =~ $blockref;
134 72
135 my $whois = $whois_cache{$self->{remote_addr}} 73 my $ra = $self->{remote_addr};
136 ||= netgeo::ip_request($self->{remote_addr}); 74 my $whois = $whois_cache{$ra} ||= netgeo::ip_request($ra);
137 75
138 my $country = "XX"; 76 my $country = "XX";
139 77
140 if ($whois =~ /^\*cy: (\S+)/m) { 78 if ($whois =~ /^\*cy: (\S+)/m) {
141 $country = uc $1; 79 $country = uc $1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines