Subject: | RE: Bug in "fetch_oui_from_cache"; Possible fix included |
Date: | Tue, 18 Aug 2009 12:06:09 +0100 |
To: | bug-Net-MAC-Vendor [...] rt.cpan.org |
From: | Lee Heagney <lee [...] ee.ucl.ac.uk> |
Brian,
I've tested this with the following script:
-------------------------------------------
#!/usr/local/bin/perl
use Net::MAC::Vendor;
my @macs = qw(00:14:4f:0f:ce:18 05:25:05:7b:6a:b2);
my $file = "/tmp/oui.txt";
my $oui = Net::MAC::Vendor::load_cache("file://$file");
print "Completed loading cache file...\n\n";
foreach $mac (@macs) {
print "Searching for: $mac...\n";
my $vendor = Net::MAC::Vendor::lookup($mac);
print "finished searching for vendor\n";
my $mac_vendor = $vendor->[0];
print "$mac => $mac_vendor\n\n";
}
----------------------------------------------
The output from running this script against the unaltered module code is:
---------------------------------------------
[lheagney@belfast /tmp]# ./macvendortest.pl
Completed loading cache file...
Searching for: 00:14:4f:0f:ce:18...
finished searching for vendor
00:14:4f:0f:ce:18 => Sun Microsystems, Inc.
Searching for: 05:25:05:7b:6a:b2...
---------------------------------------------
At this point the script hangs. If I make the edit to the Vendor.pm file
I get the following output:
--------------------------------------------
[lheagney@belfast /tmp]# ./macvendortest.pl
Completed loading cache file...
Searching for: 00:14:4f:0f:ce:18...
finished searching for vendor
00:14:4f:0f:ce:18 => Sun Microsystems, Inc.
Searching for: 05:25:05:7b:6a:b2...
finished searching for vendor
05:25:05:7b:6a:b2 =>
-------------------------------------------
As a further test I have changed the module code further:
This does NOT work, it hangs as before....
sub fetch_oui_from_cache
{
my $mac = normalize_mac( shift );
my @array = ();
exists $Cached->{ $mac } ? $Cached->{ $mac } : @array;
}
This does work:
sub fetch_oui_from_cache
{
my $mac = normalize_mac( shift );
my @array = ();
exists $Cached->{ $mac } ? $Cached->{ $mac } : \@array;
}
Regards,
Lee.
**********************************************
Lee Heagney
System administrator
Dept Electronic & Electrical Engineering
University College London
Torrington Place
London TEL 020 7679 3960
WC1E 7JE FAX 020 7388 9325