FastPing and SNMP working together
Marc Lehmann
schmorp at schmorp.de
Sun Sep 25 01:39:01 CEST 2016
On Sat, Sep 24, 2016 at 05:08:18PM +0300, Alexey Mikhailov <alexey.mikhailov at gmail.com> wrote:
> I am working on some kind of monitoring system. It has 2 types
> of tests: SNMP (using AnyEvent::SNMP) and Ping (using AnyEvent::Fastping).
Hi!
It's hard to say what is going wrong, but perl does not support forking
(from perl, although it is very tricky from C as well) in a multithreaded
program (AnyEvent::FastPing uses threads). This can cause memory
corruption and lockups quite easily, at least on POSIX systems (but, of
course, perl's fork on windows is a catastrophy as well, even if not
suffering from this specific problem :).
Even if that isn't the issue, it could be that Proclet does something
wrong - in general, using fork to do parallel processing from within
the same program is an abuse of fork, which wasn't meant for this, and
extremely hard to get working, so it's quite possible that Proclet does
something wrong, too - I would go as far as saying that it is impossible to
get it right from a module, as it requires knowledge (and control) over the
complete process, which is hard from a module that doesn't know which other
modules get loaded.
The AnyEvent::Fork (which works around this by effectively not using
fork to do parallel programming and can successfully and safely fork
form multithreaded programs) manpage expands a bit on this a bit more,
especially in the last two points:
http://pod.tst.eu/http://cvs.schmorp.de/AnyEvent-Fork/Fork.pm#PROBLEM_STATEMENT
in short, using fork to do nontrivial stuff in the child is a broken
design that will result in endless pain.
You might try to work around this in a somewhat simple way by running
e.g. AnyEvent::FastPing in a separate process (e.g. with AnyEvent::Fork)
and see if that works (takes care of the thread problem), but of course
your problems would then resurface with other modules that might use
threads (e.g. IO::AIO, or perl itself).
If that isn't the problem, you need to get rid of Proclet and try to run
your tests via a module that doesn't suffer from this by design, such
as AnyEvent::Fork::RPC - this will almost cetrainly be more effort than
using Proclet, as AnyEvent::Fork is quite low-level under under-featured,
but it's basically the only safe way to get something like fork in a
multithreaded perl program, and even allows you to use AnyEvent in the
child.
Hope this helps,
--
The choice of a Deliantra, the free code+content MORPG
-----==- _GNU_ http://www.deliantra.net
----==-- _ generation
---==---(_)__ __ ____ __ Marc Lehmann
--==---/ / _ \/ // /\ \/ / schmorp at schmorp.de
-=====/_/_//_/\_,_/ /_/\_\
More information about the anyevent
mailing list