2007/12/13, Malcolm <[EMAIL PROTECTED]>: > > Just to confirm, you do have a "use Apache::Scoreboard" in there somewhere? >
surely I used it. right now I got these exceptions in error_log: [Thu Dec 13 21:53:49 2007] [notice] child pid 4660 exit signal Segmentation fault (11) [Thu Dec 13 21:53:49 2007] [notice] child pid 14182 exit signal Segmentation fault (11) [Thu Dec 13 21:53:49 2007] [notice] child pid 14884 exit signal Segmentation fault (11) [Thu Dec 13 21:53:49 2007] [notice] child pid 14979 exit signal Segmentation fault (11) [Thu Dec 13 21:53:49 2007] [notice] child pid 15095 exit signal Segmentation fault (11) [Thu Dec 13 21:53:49 2007] [notice] child pid 15107 exit signal Segmentation fault (11) [Thu Dec 13 21:53:49 2007] [notice] child pid 15108 exit signal Segmentation fault (11) [Thu Dec 13 21:53:49 2007] [notice] child pid 15115 exit signal Segmentation fault (11) [Thu Dec 13 21:53:49 2007] [notice] child pid 15118 exit signal Segmentation fault (11) This is my full code (the key string for generating md5 is replaced here for privacy reasons): use strict; use warnings; use Socket qw(inet_aton); use POSIX qw(strftime); use Digest::MD5 qw(md5_hex); use File::Basename; use Apache::Constants qw(OK FORBIDDEN DECLINED); use Apache::Request (); use Apache::Scoreboard (); use Apache qw(exit); sub handler { my $r = shift; # We decline to handle subrequests: otherwise, a few lines down we # could get into an infinite loop. return DECLINED unless $r->is_initial_req; # # for ip whitelist # my $ip = $r->connection->remote_ip; my $ip_int = ip2int($ip); my @passip = $r->dir_config->get('PassAuthIPs'); my @passip_int; for (@passip) { if (/-/) { my ($start,$end) = split/-/; my $start_int = ip2int($start); my $end_int = ip2int($end); for (my $i=$start_int;$i<=$end_int;$i++) { push @passip_int,$i; } } else { push @passip_int, ip2int($_); } } for (@passip_int) { return OK if $ip_int == $_; } # # for limit-ip-conn # my $ip_count = 0; my $limit = $r->dir_config('MaxConnPerIP') || 0; ### my $host = $r->connection->remote_host; my $image = Apache::Scoreboard->image; for (my $parent = $image->parent; $parent; $parent = $parent->next) { my $server = $parent->server; use bytes; next if ($server->status =~ /^[\._SL]$/); ### if (($ip eq $server->client) or ($host eq $server->client)) { if ($ip eq $server->client ) { $ip_count++; } } if ($ip_count > $limit and $limit) { $r->log_reason("Client exceeded connection limit.", $r->filename); return FORBIDDEN; } # # for anti-stolen-links # my $q = Apache::Request->new($r); my $movieid = $q->param('mid'); unless (defined $movieid) { $movieid = getmid($r->uri); unless (defined $movieid) { $r->log_error("[$ip FORBIDDEN] cat't get movieid"); return FORBIDDEN; } } my $shareKey = $r->dir_config('ShareKey') || ''; my $key = 'the private string'; my $str = $q->param('a') || ''; if ($str eq md5_hex($key) ){ return OK; } else { $r->log_reason("Auth failed.", $r->filename); return FORBIDDEN; } return OK; } sub ip2int { my $ip = shift; my $nl = inet_aton($ip); die "wrong ip $!" unless defined $nl; return unpack('N',$nl); } sub getmid { my $uri = shift; my $path = (split/\?/,$uri)[0]; my $file = basename($path); my ($mid) = $file =~ /^(\d+)\D+/; return $mid; } 1; where I'm getting wrong? please help check it. Thanks a lot!