diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2014-10-19 23:49:54 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2014-10-19 23:49:54 +0300 |
commit | 44bf6638158e4171b33fcdf9183a9e6c132518dc (patch) | |
tree | edbe6c2c70052c9b646a35db00197f76c1f42a70 /whoseip/Whoseip/DB.pm | |
parent | 03c30147c1c6149af9f8070b7a92b8d0c8d18c42 (diff) | |
download | dnstools-44bf6638158e4171b33fcdf9183a9e6c132518dc.tar.gz dnstools-44bf6638158e4171b33fcdf9183a9e6c132518dc.tar.bz2 |
whoseip: bugfixes
* whoseip/Whoseip/DB.pm (ipdb_insert_unlocked): Insert into the last
page in the chain.
(ipdb_save_page): Preserve the leaf page chain.
* whoseip/whoseip.pl (cidr_to_range): Start iterating from list tail.
Diffstat (limited to 'whoseip/Whoseip/DB.pm')
-rw-r--r-- | whoseip/Whoseip/DB.pm | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/whoseip/Whoseip/DB.pm b/whoseip/Whoseip/DB.pm index fed7cd9..21a4192 100644 --- a/whoseip/Whoseip/DB.pm +++ b/whoseip/Whoseip/DB.pm @@ -414,6 +414,7 @@ sub ipdb_save_page($$) { if $dbf->{debug} > 1; $nextpage = ipdb_alloc_page($dbf, IPDB_PAGE_LEAF, nocache => 1); + $nextpage->{next} = $page->{next}; $page->{next} = $nextpage->{off}; @{$nextpage->{tab}} = @{$page->{tab}}[$i .. $#{$page->{tab}}]; $nextpage->{dirty} = 1; @@ -812,8 +813,8 @@ sub ipdb_lookup($$) { Inserts into the database I<$cidr> and the corresponding country code I<$country> and additional data I<$hashref>. -Currently, I<$cidr> must be in the form B<I<Net-address>/I<Netmask-length>>. - +Currently, I<$cidr> must be in the form B<I<Net-address>/I<Netmask-length>>. + =cut sub ipdb_insert_unlocked { my ($dbf, $cidr, $country, $href) = @_; @@ -855,11 +856,13 @@ sub ipdb_insert_unlocked { } if ($page->{tab}[LEAF_IDX]) { - print STDERR "ipdb_insert: loading leaf page from $page->{tab}[LEAF_IDX]\n" - if $dbf->{debug}; - $page = ipdb_cache_get($dbf, $page->{tab}[LEAF_IDX]); - croak "$dbf->{filename}: index page found where leaf was expected" - unless $page->{type} == IPDB_PAGE_LEAF; + for (my $off = $page->{tab}[LEAF_IDX]; $off; $off = $page->{next}) { + print STDERR "ipdb_insert: loading leaf page from $off\n" + if $dbf->{debug}; + $page = ipdb_cache_get($dbf, $off); + croak "$dbf->{filename}: index page found where leaf was expected" + unless $page->{type} == IPDB_PAGE_LEAF; + } } else { print STDERR "ipdb_insert: creating leaf page\n" if $dbf->{debug}; |