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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines