[Nagios-checkins] nagios/common macros.c,1.44,1.45
Nagios network monitoring software is enterprise server monitoring
Brought to you by:
egalstad,
sawolf-nagios
From: Andreas E. <ag...@us...> - 2010-10-28 12:31:48
|
Update of /cvsroot/nagios/nagios/common In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv22508/common Modified Files: macros.c Log Message: Make performance-data handling and checks thread safe It's a bit early to tell, but at least we've gotten rid of the horrible global macro management now, in favour of a macro struct that gets passed around. In truth though, the whole macro machinery needs a rewrite in order to make good sense. Getting all the data before we even know we need it doesn't even begin to make sense, but with this patch we can at least start using concurrent performance-data updates while checks are being started at the same time, and since notifications is currently the only thing (I hope) that isn't overly scratched by this patch, Nagios won't have any issues sending those out while other code looks to performance-data and firing up checks. As a fall-back for eventbroker modules and whatnot that references the global macro_x variable, we retain it but make it point to the global_macros.x. This requires that macros have been initialized, but any code that referenced macro_x before initialization was doomed to "undefined behaviour" earlier anyway, so the fact that they will now for certain segfault on such actions is probably an improvement. For backwards compatibility with existing modules, we let process_macros() and get_raw_command_line() exist with their previous signatures and act as wrappers for the reentrant versions providing the same functionality, passing a global 'nagios_macros *' struct as first argument. The reentrant versions are, as per best practice, named "process_macros_r()" and "get_raw_command_line_r()", respectively. I only checked NDOUtils and DNX for compatibility, so other projects may suffer. Gargantuan patch, I know. The macro machinery was far more central to the Nagios core than I first imagined. Signed-off-by: Andreas Ericsson <ae...@op...> Index: macros.c =================================================================== RCS file: /cvsroot/nagios/nagios/common/macros.c,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** macros.c 27 Oct 2010 18:53:12 -0000 1.44 --- macros.c 28 Oct 2010 12:31:40 -0000 1.45 *************** *** 51,73 **** extern timeperiod *timeperiod_list; ! char *macro_x[MACRO_X_COUNT]; ! char *macro_x_names[MACRO_X_COUNT]; ! char *macro_argv[MAX_COMMAND_ARGUMENTS]; ! char *macro_user[MAX_USER_MACROS]; ! char *macro_contactaddress[MAX_CONTACT_ADDRESSES]; ! char *macro_ondemand=NULL; ! customvariablesmember *macro_custom_host_vars=NULL; [...2154 lines suppressed...] /* sets or unsets a macro environment variable */ ! int set_macro_environment_var(char *name, char *value, int set) ! { char *env_macro_name=NULL; *************** *** 3195,3201 **** return OK; ! } #endif - - --- 3224,3228 ---- return OK; ! } #endif |