Re: Fw: Unable to build Net-Snmp with embedded perl

Bart Van Assche <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <CAO+b5-pxYmrKugsyBybM0DVaOVAsXS2bGeYWoMCg_mm-f-AU6Q@mail.gmail.com>
On Tue, Aug 9, 2011 at 4:07 PM,  <[email protected]> wrote:
> I downloaded and built with the latest 5.7.1 pre release.
>
> During the Perl tests it no longer crashed the snmpd.exe, however it still
> locks up at the same point:

The patch below fixes that lockup on my setup:

diff --git a/perl/SNMP/SNMP.pm b/perl/SNMP/SNMP.pm
index 50658a1..64e6e8b 100644
--- a/perl/SNMP/SNMP.pm
+++ b/perl/SNMP/SNMP.pm
@@ -60,16 +60,10 @@ sub AUTOLOAD {
     ($constname = $AUTOLOAD) =~ s/.*:://;
     # croak "&$module::constant not defined" if $constname eq 'constant';
     $val = constant($constname, @_ ? $_[0] : 0);
-    if ($! != 0) {
-	if ($! =~ /Invalid/) {
-	    $AutoLoader::AUTOLOAD = $AUTOLOAD;
-	    goto &AutoLoader::AUTOLOAD;
-	}
-	else {
-	    ($pack,$file,$line) = caller;
-	    die "Your vendor has not defined SNMP macro $constname, used at
$file line $line.
+    if ($val < -1) {
+	($pack,$file,$line) = caller;
+        die "Your vendor has not defined SNMP macro $constname, used
at $file line $line.
 ";
-	}
     }
     eval "sub $AUTOLOAD { $val }";
     goto &$AUTOLOAD;
diff --git a/perl/SNMP/SNMP.xs b/perl/SNMP/SNMP.xs
index dfe5791..1676776 100644
--- a/perl/SNMP/SNMP.xs
+++ b/perl/SNMP/SNMP.xs
@@ -2409,7 +2409,6 @@ constant(name, arg)
 char *name;
 int arg;
 {
-    errno = 0;
     switch (*name) {
     case 'R':
 	if (strEQ(name, "NETSNMP_CALLBACK_OP_RECEIVED_MESSAGE"))
@@ -2545,13 +2544,11 @@ int arg;
     default:
 	break;
     }
-    errno = EINVAL;
-    return 0;
+    return -EINVAL;

 not_there:
     not_here(name);
-    errno = ENOENT;
-    return 0;
+    return -ENOENT;
 }

 /*

------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system, 
user administration capabilities and model configuration. Take 
the hassle out of deploying and managing Subversion and the 
tools developers use with it. 
http://p.sf.net/sfu/wandisco-dev2dev

_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
fix-windows-perl-test-lockup.patch (application/octet-stream, 1.7 KB)
commit 8c3c831dc40663bcc7593bd75cfc5eb33e5ea774
Author: Bart Van Assche <[email protected]>
Date:   Thu Aug 11 10:31:40 2011 +0200

    CHANGES: Make the SNMP Perl module work on Windows. Background: passing errno from .xs to $! in .pm doesn t work if the Perl binaries and Net-SNMP have been compiled with different MSVC versions or in different modes (e.g. release versus debug).

diff --git a/perl/SNMP/SNMP.pm b/perl/SNMP/SNMP.pm
index 50658a1..64e6e8b 100644
--- a/perl/SNMP/SNMP.pm
+++ b/perl/SNMP/SNMP.pm
@@ -60,16 +60,10 @@ sub AUTOLOAD {
     ($constname = $AUTOLOAD) =~ s/.*:://;
     # croak "&$module::constant not defined" if $constname eq 'constant';
     $val = constant($constname, @_ ? $_[0] : 0);
-    if ($! != 0) {
-	if ($! =~ /Invalid/) {
-	    $AutoLoader::AUTOLOAD = $AUTOLOAD;
-	    goto &AutoLoader::AUTOLOAD;
-	}
-	else {
-	    ($pack,$file,$line) = caller;
-	    die "Your vendor has not defined SNMP macro $constname, used at $file line $line.
+    if ($val < -1) {
+	($pack,$file,$line) = caller;
+        die "Your vendor has not defined SNMP macro $constname, used at $file line $line.
 ";
-	}
     }
     eval "sub $AUTOLOAD { $val }";
     goto &$AUTOLOAD;
diff --git a/perl/SNMP/SNMP.xs b/perl/SNMP/SNMP.xs
index dfe5791..1676776 100644
--- a/perl/SNMP/SNMP.xs
+++ b/perl/SNMP/SNMP.xs
@@ -2409,7 +2409,6 @@ constant(name, arg)
 char *name;
 int arg;
 {
-    errno = 0;
     switch (*name) {
     case 'R':
 	if (strEQ(name, "NETSNMP_CALLBACK_OP_RECEIVED_MESSAGE"))
@@ -2545,13 +2544,11 @@ int arg;
     default:
 	break;
     }
-    errno = EINVAL;
-    return 0;
+    return -EINVAL;
 
 not_there:
     not_here(name);
-    errno = ENOENT;
-    return 0;
+    return -ENOENT;
 }
 
 /*
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.