When using asynchronous operations with callbacks, these callbacks are assumed not to die. If they do die, the perl process segmentation faults, as illustrated by this test script:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
Output:
an error at /home/peter/junk/snmpSegfault-callback-dies.pl line 10.
Segmentation fault
The provided patch (for 5.7.3 and 5.8.pre2) runs callbacks with G_EVAL
. If the callbacks fail/die, a warning is issued, but a custom handler can also be set up allowing for custom handling. Here from is the added perldoc:
=head1 Handling errors from SNMP callbacks
Callbacks given to operations such as
C<< $sess->get([['leaf',1]], sub {}) >> should not C<die>. If they do
anyway, by default a warning is issued. You can however set a global
C<$SNMP::callback_error_handler> handler for custom handling of such
errors:
$SNMP::callback_error_handler = sub {
my ($error) = @_;
printf "Handling error from callback: %s\n", $error;
# And whatever makes sense for your application...
};