[dev.icinga.com #1034] macros: Don't wipe the global macros when initializing macros #468

Closed
icinga-migration opened this Issue Dec 3, 2010 · 1 comment

Comments

Projects
None yet
1 participant
Member

icinga-migration commented Dec 3, 2010

This issue has been migrated from Redmine: https://dev.icinga.com/issues/1034

Created by mfriedrich on 2010-12-03 10:08:10 +00:00

Assignee: mfriedrich
Status: Resolved (closed on 2010-12-17 17:40:05 +00:00)
Target Version: 1.3
Last Update: 2010-12-17 17:40:05 +00:00 (in Redmine)


From: Andreas Ericsson 
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 
---

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;
 }

Changesets

2010-12-03 10:10:20 +00:00 by mfriedrich 021f382

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 <ae@op5.se>
--SNIP--

refs #1034
Member

icinga-migration commented Dec 17, 2010

Updated by mfriedrich on 2010-12-17 17:40:05 +00:00

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

icinga-migration added this to the 1.3 milestone Jan 17, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment