[icinga-checkins] icinga.org: icinga-core/mfriedrich/workers: core: free raw_command immediately after processing the macros / not needing them anymore

git at icinga.org git at icinga.org
Tue Aug 7 15:07:01 CEST 2012


Module: icinga-core
Branch: mfriedrich/workers
Commit: acc42be5973e78f3106c39030c8582d5b256fcad
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=acc42be5973e78f3106c39030c8582d5b256fcad

Author: Michael Friedrich <michael.friedrich at univie.ac.at>
Date:   Tue Aug  7 14:51:35 2012 +0200

core: free raw_command immediately after processing the macros / not needing them anymore

previously, we were doing that later on in the error sections.

---

 base/checks.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/base/checks.c b/base/checks.c
index 9cbf6a5..d5f370c 100644
--- a/base/checks.c
+++ b/base/checks.c
@@ -325,13 +325,15 @@ int run_async_service_check(service *svc, int check_options, double latency, int
 
 	/* process any macros contained in the argument */
 	process_macros_r(&mac, raw_command, &processed_command, 0);
+
+	my_free(raw_command);
+
 	if (processed_command == NULL) {
 		clear_volatile_macros_r(&mac);
 		log_debug_info(DEBUGL_CHECKS, 0, "Processed check command for service '%s' on host '%s' was NULL - aborting.\n", svc->description, svc->host_name);
 		if (preferred_time)
 			*preferred_time += (svc->check_interval * interval_length);
 		svc->latency = old_latency;
-		my_free(raw_command);
 		return ERROR;
 	}
 
@@ -350,7 +352,6 @@ int run_async_service_check(service *svc, int check_options, double latency, int
 		clear_volatile_macros_r(&mac);
 		svc->latency = old_latency;
 		my_free(processed_command);
-		my_free(raw_command);
 		return OK;
 	}
 #endif
@@ -2292,6 +2293,7 @@ int execute_sync_host_check_3x(host *hst) {
 	/* process any macros contained in the argument */
 	process_macros_r(&mac, raw_command, &processed_command, 0);
 	if (processed_command == NULL) {
+		my_free(raw_command);
 		clear_volatile_macros_r(&mac);
 		return ERROR;
 	}
@@ -2308,6 +2310,7 @@ int execute_sync_host_check_3x(host *hst) {
 
 	log_debug_info(DEBUGL_COMMANDS, 1, "Raw host check command: %s\n", raw_command);
 	log_debug_info(DEBUGL_COMMANDS, 0, "Processed host check ommand: %s\n", processed_command);
+	my_free(raw_command);
 
 	/* clear plugin output and performance data buffers */
 	my_free(hst->plugin_output);
@@ -2339,7 +2342,6 @@ int execute_sync_host_check_3x(host *hst) {
 
 	/* free memory */
 	my_free(temp_plugin_output);
-	my_free(raw_command);
 	my_free(processed_command);
 
 	/* a NULL host check command means we should assume the host is UP */
@@ -2552,6 +2554,9 @@ int run_async_host_check_3x(host *hst, int check_options, double latency, int sc
 
 	/* process any macros contained in the argument */
 	process_macros_r(&mac, raw_command, &processed_command, 0);
+
+	my_free(raw_command);
+
 	if (processed_command == NULL) {
 		clear_volatile_macros_r(&mac);
 		log_debug_info(DEBUGL_CHECKS, 0, "Processed check command for host '%s' was NULL - aborting.\n", hst->name);





More information about the icinga-checkins mailing list