[icinga-checkins] icinga.org: icinga-core/mfriedrich/core: 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:34:45 CEST 2012


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

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 fa7470b..fb8d17a 100644
--- a/base/checks.c
+++ b/base/checks.c
@@ -589,13 +589,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;
 	}
 
@@ -614,7 +616,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
@@ -2927,6 +2928,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;
 	}
@@ -2943,6 +2945,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);
@@ -2974,7 +2977,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 */
@@ -3196,6 +3198,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