Bug #1034

macros: Don't wipe the global macros when initializing macros

Added by dnsmichi over 3 years ago. Updated over 3 years ago.

Status:ResolvedStart date:12/03/2010
Priority:NormalDue date:
Assignee:dnsmichi% Done:

100%

Category:-
Target version:Icinga 1.x - 1.3
Icinga Version: OS Version:

Description

From: Andreas Ericsson <ae@op5.se>
Date: Fri, 29 Oct 2010 10:25:28 +0000 (+0000)
Subject: macros: Don't wipe the global macros when initializing macros
X-Git-Url: http://git.nagiosprojects.org/?p=nagios.git;a=commitdiff_plain;h=32e7a3a58e37c5e260fe375bd7fe79e4f6ef4074;hp=423762469e47d53561c9276295b20b74605762e0

macros: Don't wipe the global macros when initializing macros

Instead we must use clear_volatile_macros() on the global macro
struct. Constant macros are safely free()'d individually when
they're set, so this patch makes perfect sense.

Signed-off-by: Andreas Ericsson <ae@op5.se>
---

diff --git a/common/macros.c b/common/macros.c
index 0cd9453..c54c9ee 100644
--- a/common/macros.c
+++ b/common/macros.c
@@ -2462,8 +2462,19 @@ char *get_url_encoded_string(char *input)
 int init_macros(void)
 {
     init_macrox_names();
-    memset(&global_macros, 0, sizeof(global_macros));
+
+    /*
+     * non-volatile macros are free()'d when they're set.
+     * We must do this in order to not lose the constant
+     * ones when we get SIGHUP or a RESTART_PROGRAM event
+     * from the command fifo. Otherwise a memset() would
+     * have been better.
+     */
+    clear_volatile_macros(&global_macros);
+
+    /* backwards compatibility hack */
     macro_x = global_macros.x;
+
     return OK;
 }

Associated revisions

Revision 021f3827
Added by dnsmichi over 3 years ago

macros: Don't wipe the global macros when initializing macros (Andreas Ericsson) #1034

--SNIP--
Instead we must use clear_volatile_macros() on the global macro
struct. Constant macros are safely free()'d individually when
they're set, so this patch makes perfect sense.

Signed-off-by: Andreas Ericsson <>
--SNIP--

refs #1034

History

#1 Updated by dnsmichi over 3 years ago

  • Status changed from Assigned to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF