Changeset 804


Ignore:
Timestamp:
11/09/20 18:21:27 (3 years ago)
Author:
Kris Deugau
Message:

/trunk

Fix mysterious 'Variable "$foo" will not stay shared at ...' error by
converting the nested sub in _updateserial() to an anonymous sub, because
nested subs aren't really a properly supported thing as per eg
https://www.perlmonks.org/bare/?node_id=137292.

Several other instances of nested subs should arguably be converted as well,
although they shouldn't matter so much as they haven't triggered the error,
and as of a quick review don't make use of "parent" sub variables the way
the one in _updateserial() did.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r795 r804  
    508508# the serial effectively runs backwards.  technically this breaks AXFR slaves.
    509509
     510##perlnote
     511# Nested subs... aren't.  Subs have file or execution scope, sort of (not sure which ATM), so we
     512# have to abuse the "anonymous sub" construct and bend our code in a pretzel to work around this limitation.
     513
    510514  # heavy lifting done in this sub-sub.  updates may be needed on a forward zone, reverse zone, or both, depending.
    511   sub __doupdate {
     515  my $serup = sub {
    512516    my $rev = shift;
    513517    my $zid = shift;
     
    540544      # Your llama is on fire
    541545    }
    542   }
     546  };
    543547
    544548  if ($args{rdns_id}) {
    545     __doupdate('y', $args{rdns_id});
     549    &$serup('y', $args{rdns_id});
    546550  }
    547551
    548552  if ($args{domain_id}) {
    549     __doupdate('n', $args{domain_id});
     553    &$serup('n', $args{domain_id});
    550554  }
    551555
Note: See TracChangeset for help on using the changeset viewer.