Skip Menu |
 
rt.cpan.org will be shut down on March 1st, 2021.

This queue is for tickets about the Net-SNMP CPAN distribution.

Report information
The Basics
Id: 100341
Status: new
Priority: 0/
Queue: Net-SNMP

People
Owner: Nobody in particular
Requestors: jl2076 [...] att.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Net::SNMP - new class instances do not reset the debug mask set by previous class instances
Date: Fri, 14 Nov 2014 21:12:45 +0000
To: "bug-Net-SNMP [...] rt.cpan.org" <bug-Net-SNMP [...] rt.cpan.org>
From: "LIVERMAN, JAMES" <jl2076 [...] att.com>
Download (untitled) / with headers
text/plain 5.5k
It seems each instance of Net::SNMP does not reset the debug mask. Here is my system info: Linux : perl -v This is perl 5, version 12, subversion 3 (v5.12.3) built for i686-linux-thread-multi Copyright 1987-2010, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit. Complete documentation for Perl, including FAQ lists, should be found on this system using "man perl" or "perldoc perl". If you have access to the Internet, point your browser at http://www.perl.org/, the Perl Home Page. Linux : perl -V | sed -n '/@INC/,$p' | xargs -i -- find {} -name 'SNMP.pm' 2>/dev/null /lib/perl5.12.3/site_perl/5.12.3/Net/SNMP.pm /lib/perl5/site_perl/5.12.3/Net/SNMP.pm Linux : grep 'our \$VERSION' /lib/perl5.12.3/site_perl/5.12.3/Net/SNMP.pm our $VERSION = 'v6.0.1'; Linux : grep 'our \$VERSION' /lib/perl5/site_perl/5.12.3/Net/SNMP.pm our $VERSION = 'v6.0.1'; Linux : uname -a Linux sndnm923 2.6.18-348.1.1.el5 #1 SMP Fri Dec 14 05:25:59 EST 2012 x86_64 x86_64 x86_64 GNU/Linux Linux : cat /etc/redhat-release Red Hat Enterprise Linux Server release 5.9 (Tikanga) Here is code showing the issue: use strict; use warnings; use Net::SNMP; my $version = 'version'; my $community = 'community'; my $hostname = 'hostname'; my $instance_1 = Net::SNMP->session( -version => $version, -community => $community, -hostname => $hostname ); # default debug mask of 0x00 if($instance_1){ printf("DEBUG FOR 1: %d\n", $instance_1->debug()); } my $instance_2 = Net::SNMP->session( -version => $version, -community => $community, -hostname => $hostname ); # default debug mask of 0x00 if($instance_2){ printf("DEBUG FOR 2: %d\n", $instance_2->debug()); } my $instance_3 = Net::SNMP->session( -version => $version, -community => $community, -hostname => $hostname, -debug => 1 ); # future instances will also have debug mask set to 0x01 if($instance_3){ printf("DEBUG FOR 3: %d\n", $instance_3->debug()); } my $instance_4 = Net::SNMP->session( -version => $version, -community => $community, -hostname => $hostname ); # left-over debug mask of 0x01 if($instance_4){ printf("DEBUG FOR 4: %d\n", $instance_4->debug()); } my $instance_5 = Net::SNMP->session( -version => $version, -community => $community, -hostname => $hostname ); # left-over debug mask of 0x01 if($instance_5){ printf("DEBUG FOR 5: %d\n", $instance_5->debug()); } my $instance_6 = Net::SNMP->session( -version => $version, -community => $community, -hostname => $hostname, -debug => 2 ); # future instances will also have debug mask set to 0x02 if($instance_6){ printf("DEBUG FOR 6: %d\n", $instance_6->debug()); } my $instance_7 = Net::SNMP->session( -version => $version, -community => $community, -hostname => $hostname ); # left-over debug mask of 0x02 if($instance_7){ printf("DEBUG FOR 7: %d\n", $instance_7->debug()); } my $instance_8 = Net::SNMP->session( -version => $version, -community => $community, -hostname => $hostname ); # left-over debug mask of 0x02 if($instance_8){ printf("DEBUG FOR 8: %d\n", $instance_8->debug()); } my $instance_9 = Net::SNMP->session( -version => $version, -community => $community, -hostname => $hostname, -debug => 0 ); # future instances will also have debug mask set to 0x00 if($instance_9){ printf("DEBUG FOR 9: %d\n", $instance_9->debug()); } my $instance_10 = Net::SNMP->session( -version => $version, -community => $community, -hostname => $hostname ); # left-over debug mask of 0x00 if($instance_10){ printf("DEBUG FOR 10: %d\n", $instance_10->debug()); } my $instance_11 = Net::SNMP->session( -version => $version, -community => $community, -hostname => $hostname ); # left-over debug mask of 0x00 if($instance_11){ printf("DEBUG FOR 11: %d\n", $instance_11->debug()); } exit 0; ^D DEBUG FOR 1: 0 DEBUG FOR 2: 0 DEBUG FOR 3: 1 DEBUG FOR 4: 1 DEBUG FOR 5: 1 DEBUG FOR 6: 2 DEBUG FOR 7: 2 DEBUG FOR 8: 2 DEBUG FOR 9: 0 DEBUG FOR 10: 0 DEBUG FOR 11: 0 It seems this can be fixed by making debug an "instance variable" instead of a "class variable" OR by manually resetting it in the constructor i.e. calling $this->debug(0x00) around line 325: 304 sub new 305 { 306 my ($class, %argv) = @_; 307 308 # Create a new data structure for the object 309 my $this = bless { 310 '_callback' => undef, # Callback 311 '_context_engine_id' => undef, # contextEngineID 312 '_context_name' => undef, # contextName 313 '_delay' => 0, # Message delay 314 '_hostname' => q{}, # Hostname 315 '_discovery_queue' => [], # Pending message queue 316 '_error' => undef, # Error message 317 '_nonblocking' => FALSE, # [Non-]blocking flag 318 '_pdu' => undef, # Message/PDU object 319 '_security' => undef, # Security Model object 320 '_translate' => TRANSLATE_ALL, # Translation mask 321 '_transport' => undef, # Transport Domain object 322 '_transport_argv' => [], # Transport object argv 323 '_version' => SNMP_VERSION_1, # SNMP version 324 }, $class; 325 326 # Parse the passed arguments 327 328 for (keys %argv) { 329 330 if (/^-?debug$/i) { 331 $this->debug(delete $argv{$_}); James Liverman Professional-Applications Developer Service Assurance M5 Task Automation CoE AT&T Business Solutions 919-864-3343
Download (untitled) / with headers
text/html 29.1k

Message body is not shown because it is too large.



This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.