netreg-devel: Question about a subtle bug.

David Nolan vitroth at cmu.edu
Thu Nov 16 07:49:37 EST 2006


On 11/15/06, Sean Spillane <sean.russell.spillane at gmail.com> wrote:
> Hi! I'm trying to make an API call to CMU::Netdb::modify_machine() and I am
> running into trouble. I pass in the following as arguments to the function:
>
> A DB hash from CMU::Netdb::lw_db_connect()
> 'netreg', which I think is the UID that the DB wants
> The ID number for the machine. (40637 in this case)
> The last version string for the machine.
> A hashref containing
> id => '40637'
> expires => '2006-10-15' I think that this is the correct calling style, but
> I run into trouble from a weird place. Inside the CMU::Netdb::
> add_mod_machine_static() function (Yes, the machine is static), I get an
> error:
>  /home/netreg/lib/CMU/Netdb/machines_subnets.pm:1422
> :>Couldn't find machine.ip_address_ttl!
>  $VAR1 = {
>           'ip_address_ttl' => '0',
>            'mode' => 'static',
>            'comment_lvl9' => '',
>           'mac_address' => '000D56988A3C',
>            'host_name_ttl' => '0',
>            'ip_address_subnet' => 278,
>           'id' => '40637',
>            'ip_address' => '169.226.142.86',
>            'comment_lvl5' => '',
>           'flags' => '',
>           'version' => '2004-09-24 10:05:42',
>            'account' => '',
>            'host_name_zone' => '143',
>           'ip_address_zone' => '144',
>            'created' => '2004-09-24 10:05:42',
>            'comment_lvl1' => '',
>           'host_name' => ' MSUTHERLANDOFF.BA.ALBANY.EDU',
>           'fuckall.ip_address_ttl' => 42,
>            'expires' => '2006-10-15'
>          };
> $VAR2 = [
>            'id',
>           'mac_address',
>           'host_name',
>            'ip_address',
>           'mode',
>            'flags',
>           'comment_lvl1',
>           'comment_lvl5',
>            'comment_lvl9',
>           'account',
>           'host_name_ttl',
>            'ip_address_ttl',
>           'host_name_zone',
>           'ip_address_zone',
>            'ip_address_subnet',
>           'version',
>           'created',
>            'expires'
>         ];
>
> Notice how the @machine_fields array that is referenced by the function
> ($VAR2 above) seems to have lost the " machine." prefixes on each of its
> fields. I cannot figure out why. When I explicitly redeclare the variable as
> a my variable and set it to
> @CMU::Netdb::structure::machine_fields, the problem goes
> away. I therefore suggest that, since no mention was made that no one can
> modify @CMU::Netdb::structure::machine_fields and there is
> at least one place in CMU::Netdb::list_machines() where an unshift does
> modify it, that a my variable be included in the header of
> CMU::Netdb::add_mod_machine_static(), setting it to
> @CMU::Netdb::structure::machine_fields. Doing this seems to
> solve the problem, though perhaps I am just calling the function
> incorrectly. Can you folks help me? I need to know what I should do.


Sean,

If you're doing somethign that is modifying the machine_fields list
that would be causing this problem.  Note that list_machines is *not*
modifying that structure, but prepending a reference to it onto the
result data before returning that data, which is probably the source
of your problem.  I suspect that you're taking the first row of a
list_machines result and modifying it...  Try copying that array
before modifying it.  something like:
my @header_row = @{$result->[0]};

The better thing to do would probably be to make all of the list_*
routines copy the relevant array rather then referencing it, but thats
the way it works right now...

-David


More information about the Netreg-devel mailing list