Changeset 366 for branches/stable/cgi-bin/main.cgi
- Timestamp:
- 10/09/07 13:08:58 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/cgi-bin/main.cgi
r356 r366 81 81 print "<div type=heading align=center>Adding $cidr as master block....</div>\n"; 82 82 83 # Allow transactions, and raise an exception on errors so we can catch it later. 84 # Use local to make sure these get "reset" properly on exiting this block 85 local $ip_dbh->{AutoCommit} = 0; 86 local $ip_dbh->{RaiseError} = 1; 87 88 # Wrap the SQL in a transaction 89 eval { 90 $sth = $ip_dbh->prepare("insert into masterblocks values ('$webvar{cidr}')"); 91 $sth->execute; 92 93 # Unrouted blocks aren't associated with a city (yet). We don't rely on this 94 # elsewhere though; legacy data may have traps and pitfalls in it to break this. 95 # Thus the "routed" flag. 96 97 $sth = $ip_dbh->prepare("insert into freeblocks (cidr,maskbits,city,routed)". 98 " values ('$webvar{cidr}',".$cidr->masklen.",'<NULL>','n')"); 99 $sth->execute; 100 101 # If we get here, everything is happy. Commit changes. 102 $ip_dbh->commit; 103 }; # end eval 104 105 if ($@) { 106 my $msg = $@; 83 my ($code,$msg) = addMaster($ip_dbh, $webvar{cidr}); 84 85 if ($code eq 'FAIL') { 107 86 carp "Transaction aborted because $msg"; 108 eval { $ip_dbh->rollback; };109 87 syslog "err", "Could not add master block '$webvar{cidr}' to database: '$msg'"; 110 88 printError("Could not add master block $webvar{cidr} to database: $msg");
Note:
See TracChangeset
for help on using the changeset viewer.