X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FIP_Mixin.pm;h=3ec7693134ab430356a08ef4476a88aa3878f4f8;hb=e95a28ea14289ffcfa652bff9b179d3820b56242;hp=b3c10528c0e90d645ced635231d5aeb45bf8beb5;hpb=430b2c784d2ee9ea5be00b821d2dbd27279ef132;p=freeside.git diff --git a/FS/FS/IP_Mixin.pm b/FS/FS/IP_Mixin.pm index b3c10528c..3ec769313 100644 --- a/FS/FS/IP_Mixin.pm +++ b/FS/FS/IP_Mixin.pm @@ -4,6 +4,7 @@ use strict; use NetAddr::IP; use FS::addr_block; use FS::router; +use FS::addr_range; use FS::Record qw(qsearch); use FS::Conf; # careful about importing anything here--it will end up in a LOT of @@ -129,6 +130,10 @@ sub assign_ip_addr { my $self = shift; my %opt = @_; + #otherwise we'll get the same assignment for concurrent identical calls + # this will serialize them + $_->lock_table foreach @subclasses; + my @blocks; my $na = $self->NetAddr; @@ -152,14 +157,14 @@ sub assign_ip_addr { # don't exit early on assigning a free address--check the rest of # the blocks to see if the current address is in one of them. if (!$new_addr) { - $new_addr = $block->next_free_addr->addr; + $new_addr = $block->next_free_addr; $new_block = $block; } } return 'No IP address available on this router' unless $new_addr; - $self->ip_addr($new_addr); + $self->ip_addr($new_addr->addr); $self->addr_block($new_block); ''; }