Skip Menu |

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

Report information
The Basics
Id: 6320
Status: resolved
Priority: 0/
Queue: Net-Pcap

People
Owner: SAPER [...] cpan.org
Requestors: voodoo_alex [...] mail.ru
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.05
Fixed in: 0.08



Subject: Net::Pcap::loop() conflict with alarm() on linux 2.4 kernel
[Module] Net::Pcap-0.05 [Perl] v5.8.1 built for i386-linux-thread-multi [OS] Linux <cutted>.net 2.4.22-1.2174.nptl.asp #1 Fri Feb 20 06:26:58 EET 2004 i686 i686 i386 GNU/Linux (this is ASPLinux 9.2) I am use libpcap-0.8.3 for build this module on some linux and solaris servers. On solaris and linux 2.2 my program work fine, but on linux 2.4 boxes not! ---[part of program]--- $SIG{ALRM} = \&alarm_handler; # # Start main loop # alarm(5); Net::Pcap::loop($pcd, -1, \&process_packet, 0) || die; # # Handlers # sub alarm_handler { alarm(5); <do some work> } sub process_packet { my($user_data, $hdr, $pkt) = @_; <do some work> } ---[part of program]--- sub process_packet() must be executed on every packet passed throutput filter, sub alarm_handler() must be executed every 5 seconds. But on linux 2.4 boxes sub alarm_handler() executed every 5 seconds ONLY IF Net::Pcap::loop() hook packets, and if no packets acceptable by pcap filter - alarm_handler() NOT executed any time.
[guest - Mon May 17 01:57:00 2004]: Show quoted text
> I am use libpcap-0.8.3 for build this module on some linux and solaris > servers. On solaris and linux 2.2 my program work fine, but on > linux 2.4 boxes not!
I confirm the bug on Linux 2.6. Rewriting the program in C doesn't expose the same behaviour so the error doesn't lie in the libpcap library. As the program only uses pcap_loop(), and the XS wrapper for this fnuction is almost trivial, I'd say the problem isn't in Pcap.xs either, but maybe in Perl or in the interaction between Perl, XS and libpcap. I'll request advice from a p5porter. -- Close the world, txEn eht nepO.
From: saper [...] cpan.org
Rafaël Garcia-Suarez explained me the reason: this is because since Perl 5.7.3 signals are deferred. This is documented in perlipc[1]. The solution is to modify this behaviour by setting the PERL_SIGNALS_UNSAFE flag. This can be done before starting Perl by setting the PERL_SIGNALS environment variable to "unsafe" (see perlrun[2]), but a better solution is to do that directly in the XS code. Rafaël gave me a patch that I now need to work out so it acn be controlled by an option at load. [1] http://perldoc.perl.org/perlipc.html#Deferred-Signals-(Safe-Signals) [2] http://perldoc.perl.org/perlrun.html#ENVIRONMENT Thanks for the report -- Close the world, txEn eht nepO.
Fix applied, will be in 0.08 release. -- Close the world, txEn eht nepO.