Changeset 371 for trunk/cgi-bin/main.cgi


Ignore:
Timestamp:
11/27/07 12:27:45 (16 years ago)
Author:
Kris Deugau
Message:

/trunk

Merge bugfixes and enhancements from /branches/stable r360 through r369

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/cgi-bin/main.cgi

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