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

Michael Friedrich michael.friedrich at univie.ac.at
Wed Feb 9 16:35:37 CET 2011


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 
<http://gnu.org/licenses/gpl.html>
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:
<http://www.gnu.org/software/gdb/bugs/>...
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 Vienna, Austria

email: 	michael.friedrich at univie.ac.at
phone: 	+43 1 4277 14359
fax: 	+43 1 4277 14338
web:	http://www.univie.ac.at/zid
	http://www.aco.net

Icinga Core&  IDOUtils Developer
http://www.icinga.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-move-thread-safe-macro-function-prototypes-with-suff.patch
Type: text/x-diff
Size: 61824 bytes
Desc: not available
URL: <https://www.monitoring-lists.org/archive/developers/attachments/20110209/aa0e5ee0/attachment.patch>
-------------- next part --------------
------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
-------------- next part --------------
_______________________________________________
Nagios-devel mailing list
Nagios-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-devel


More information about the Developers mailing list