Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions lib/Netdot/Model/Ipblock.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1090,19 +1090,16 @@ sub fast_update{
my $attrs = $ips->{$address};
# Convert address to decimal format
my $dec_addr = $class->ip2int($address);

eval {
$sth2->execute($dec_addr, $attrs->{prefix}, $attrs->{version},

my $rows = $sth1->execute($attrs->{timestamp}, $dec_addr);
if ($rows == 0){
eval {
$sth2->execute($dec_addr, $attrs->{prefix}, $attrs->{version},
$attrs->{status}, $attrs->{timestamp}, $attrs->{timestamp},
);
};
if ( my $e = $@ ){
# Probably duplicate. Try to update.
eval {
$sth1->execute($attrs->{timestamp}, $dec_addr);
};
if ( my $e2 = $@ ){
$logger->error($e2);
if ( my $e = $@ ){
$logger->error($e);
}
}
}
Expand Down
32 changes: 14 additions & 18 deletions lib/Netdot/Model/PhysAddr.pm
Original file line number Diff line number Diff line change
Expand Up @@ -185,29 +185,25 @@ sub fast_update {
foreach my $address ( keys %$macs ){
$sth->execute($address, $timestamp, $timestamp);
}
}else{
# Build SQL queries
my $sth1 = $dbh->prepare_cached("UPDATE physaddr SET last_seen=? WHERE address=?");

}else{
# Build SQL queries
my $sth1 = $dbh->prepare_cached("UPDATE physaddr SET last_seen=? WHERE address=?");
my $sth2 = $dbh->prepare_cached("INSERT INTO physaddr (address,first_seen,last_seen,static)
VALUES (?, ?, ?, '0')");
VALUES (?, ?, ?, '0')");

# Now walk our list
foreach my $address ( keys %$macs ){
eval {
$sth2->execute($address, $timestamp, $timestamp);
};
if ( my $e = $@ ){
# Probably duplicate. That's OK. Update
# Now walk our list
foreach my $address ( keys %$macs ){
# this should not fail unless the database connection is broken
my $rows = $sth1->execute($timestamp, $address);
if ($rows == 0){
eval {
$sth1->execute($timestamp, $address);
$sth2->execute($address, $timestamp, $timestamp);
};
if ( my $e2 = $@ ){
# Something else is wrong
$logger->error($e2);
}
if ( my $e1 = $@ ){
$logger->error($e1);
}
}
}
}
}

my $end = time;
Expand Down