[PATCH] move thread safe macro function prototypes with suffix _r and restore old compatible prototypes again

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

[PATCH] move thread safe macro function prototypes with suffix _r and restore old compatible prototypes again

Post by Guest »

This is a multi-part message in MIME format.
--------------010002040006070105000502
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hi there,

I had a little chat with Sven Nierlein yesterday about the compatibility
of mod_gearman to current Nagios and Icinga versions. Both HEADs contain
the recent changes by Andreas regarding the thread safety for macros,
while the released versions don't have that.
mod_gearman makes use of the NEB_CALLBACK_OVERRIDE/CANCEL and in order
to run a check on their own, some logic on doing a check is copied from
base/checks.c including the clear_volatile_macros() function.

Since this is now changed into the thread-safe implementation requiring
nagios_macros* mac as argument, mod_gearman will produce a segfault.
Naturally, a workaround on the module would resolve that when Nagios
gets released, but possibly other NEB modules (or just older versions of
mod_gearman or mklivestatus e.g. in packages) are using that
functionality too, and won't work anymore.
As far as I have checked against the source code, Merlin does not make
use of those, neither do *DOUtils. On MK Livestatus I do remember some
flaws but on the latest innovation release (not stable), those seem to
be resolved. But as on previous changes, this might be a hidden source
which breaks everything.


In order to keep that clean, straight forward and compatible with older
releases, I'd like to suggest the attached patch against the current
Nagios git HEAD (from git.op5.org) which does basically the following:

* rename *_macro() into *_macro_r()
* add the non thread safe void argument function *_macro() again,
calling *_macro_r() with &global_macros argument
* put both versions into the macro.h
* replace all internal core functionality to use the thread safe version

More on the issue at https://dev.icinga.org/issues/1200 - it's
implemented already in Icinga and will be merged to master soon.

Having this applied and running, mod_gearman and livestatus are working
flawlessly on Nagios Core on my dev box (daemon and gdb).
The patch runs in combination with Icinga Core too, slightly changed on
the source, and already pushed to git.

See tests and gdb below.

Thoughts/comments?

Kind regards,
Michael

==
make test

./test_timeperiods.....ok 2491/6043# Failed (TODO) test
(test_timeperiods.c:main() at line 423)
# Failed (TODO) test (test_timeperiods.c:main() at line 436)
# Failed (TODO) test (test_timeperiods.c:main() at line 449)
# Failed (TODO) test (test_timeperiods.c:main() at line 462)
# Failed (TODO) test (test_timeperiods.c:main() at line 509)
./test_timeperiods.....ok
./test_nagios_config...ok
./test_xsddefault......ok
./test_checks..........ok
All tests successful.
Files=6, Tests=6099, 1 wallclock secs ( 0.28 cusr + 0.24 csys = 0.52 CPU)


==
gdb

~/nagios/nagios $ sudo gdb base/nagios
GNU gdb (GDB) Red Hat Enterprise Linux (7.0.1-23.el5_5.2)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later

This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
...
Reading symbols from /home/xxx/nagios/nagios/base/nagios...done.
(gdb) run /usr/local/nagios/etc/nagios.cfg
Starting program: /home/xxx/nagios/nagios/base/nagios
/usr/local/nagios/etc/nagios.cfg
[Thread debugging using libthread_db enabled]

Nagios Core 3.2.3
Copyright (c) 2009-2010 Nagios Core Development Team and Community
Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 10-03-2010
License: GPL

Website: http://www.nagios.org
Nagios 3.2.3 starting... (PID=19360)
Local time is Wed Feb 09 16:10:48 CET 2011
[New Thread 0x40a00940 (LWP 19363)]
[New Thread 0x41401940 (LWP 19364)]



--
DI (FH) Michael Friedrich

Vienna University Computer Center
Universitaetsstrasse 7 A-1010 Vi

...[email truncated]...


This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked