[icinga-checkins] icinga.org: icinga-core/fix/sorting-allunhandledproblems-5886: classic-ui: fix status.cgi gets stuck in loop when sorting on "All Unhandled Problems " #5886

git at icinga.org git at icinga.org
Wed Jun 4 00:56:59 CEST 2014


Module: icinga-core
Branch: fix/sorting-allunhandledproblems-5886
Commit: 9c742f7d9c070d19df7c13b685332f2fc032f431
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=9c742f7d9c070d19df7c13b685332f2fc032f431

Author: Ricardo Bartels <ricardo at bitchbrothers.com>
Date:   Wed Jun  4 00:40:56 2014 +0200

classic-ui: fix status.cgi gets stuck in loop when sorting on "All Unhandled Problems" #5886

with the fix for #4404 it was introduced to sort hosts again before
displaying them. This way "statussort_list" was reused. Due to not
properly resetting "statussort_list" to NULL in "free_sort_list",
"sort_status_data" wasn't working properly as it expects
"statussort_list" to be NULL when called.
this also fixes a bug where hosts were sorted only ascending and
sort option wasn't displayed in "HOST_SERVICE_DETAIL" style.

refs: #5886
refs: #5694
whatthecommit: a few bits tried to escape, but we caught them

---

 Changelog    |    4 ++++
 cgi/status.c |   11 +++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/Changelog b/Changelog
index 9590d32..f76f0a3 100644
--- a/Changelog
+++ b/Changelog
@@ -26,6 +26,10 @@ ENHANCEMENTS
 
 * classic ui: start with unhandled problems view instead of TAC #4817 - MF
 
+FIXES
+
+* classic ui: fix status.cgi gets stuck in loop when sorting on "All Unhandled Problems" #5886 - RB
+
 
 1.11.4 - 28/05/2014
 
diff --git a/cgi/status.c b/cgi/status.c
index 549f74d..28ccab4 100644
--- a/cgi/status.c
+++ b/cgi/status.c
@@ -242,6 +242,7 @@ int sort_type = SORT_NONE;				/**< defines sort order  */
 int sort_option = SORT_HOSTNAME;			/**< defines after which column is sorted */
 int sort_object = SERVICE_STATUS;			/**< defines if service or hoststatus is sorted */
 int hosts_need_to_be_sorted_again = FALSE;		/**< if we have hosts with no services and no sort option is given, then we need to sort the hosts alphabetically again */
+int user_sorted_manually = FALSE;			/**< will be set if user used sorting, needed to distinct between default sort of @ref hosts_need_to_be_sorted_again or not */
 
 /** @name status data counters vars
     @{ **/
@@ -1857,6 +1858,7 @@ int process_cgivars(void) {
 			}
 
 			sort_type = atoi(value);
+			user_sorted_manually = TRUE;
 		}
 
 		/* we found the sort option argument */
@@ -1867,6 +1869,7 @@ int process_cgivars(void) {
 			}
 
 			sort_option = atoi(value);
+			user_sorted_manually = TRUE;
 		}
 
 		/* we found the sort object argument */
@@ -1880,6 +1883,8 @@ int process_cgivars(void) {
 				sort_object = HOST_STATUS;
 			else if (!strcmp(value, "services"))
 				sort_object = SERVICE_STATUS;
+
+			user_sorted_manually = TRUE;
 		}
 
 		/* we found the embed option */
@@ -2886,7 +2891,7 @@ void show_host_detail(void) {
 
 	/* sort status data if necessary */
 	if ((sort_type != SORT_NONE && sort_object == HOST_STATUS) || hosts_need_to_be_sorted_again == TRUE) {
-		result = sort_status_data(HOST_STATUS, (hosts_need_to_be_sorted_again == TRUE) ? SORT_ASCENDING : sort_type, sort_option);
+		result = sort_status_data(HOST_STATUS, (hosts_need_to_be_sorted_again == TRUE && user_sorted_manually == FALSE) ? SORT_ASCENDING : sort_type, sort_option);
 		if (result == ERROR)
 			use_sort = FALSE;
 		else
@@ -2928,7 +2933,7 @@ void show_host_detail(void) {
 		print_displayed_names(display_type);
 		printf("</div>\n");
 
-		if (use_sort == TRUE && hosts_need_to_be_sorted_again == FALSE) {
+		if (use_sort == TRUE && user_sorted_manually == TRUE && sort_object == HOST_STATUS) {
 			printf("<div align='center' class='statusSort'>Entries sorted by <b>");
 			if (sort_option == SORT_HOSTNAME)
 				printf("host name");
@@ -6523,6 +6528,8 @@ void free_sort_list(void) {
 		free(this_sort);
 	}
 
+	statussort_list = NULL;
+
 	return;
 }
 



More information about the icinga-checkins mailing list