diff --git a/NEWS b/NEWS index 79377476..48ccaa6d 100644 --- a/NEWS +++ b/NEWS @@ -70,6 +70,7 @@ NEWS * [mod_webdav] readdir POSIX compat (fixes #1826) * [mod_expire] reset caching response headers for error docs (fixes #1919) * [mod_status] page refresh option (fixes #2170) + * [mod_status] table w/ count of con states (fixes #2427) - 1.4.39 - 2016-01-02 * [core] fix memset_s call (fixes #2698) diff --git a/src/mod_status.c b/src/mod_status.c index 955554cd..031fa734 100644 --- a/src/mod_status.c +++ b/src/mod_status.c @@ -211,6 +211,10 @@ static handler_t mod_status_handle_server_status_html(server *srv, connection *c int days, hours, mins, seconds; + /*(CON_STATE_CLOSE must be last state in enum connection_state_t)*/ + int cstates[CON_STATE_CLOSE+3]; + memset(cstates, 0, sizeof(cstates)); + buffer_copy_string_len(b, CONST_STR_LEN( "\n" "\n")); - - buffer_append_string_len(b, CONST_STR_LEN( - "
\n
legend\n"
-		". = connect, C = close, E = hard error, k = keep-alive\n"
-		"r = read, R = read-POST, W = write, h = handle-request\n"
-		"q = request-start,  Q = request-end\n"
-		"s = response-start, S = response-end\n"));
+	buffer_append_string_len(b, CONST_STR_LEN("
\n
\n"));
 
 	buffer_append_string_len(b, CONST_STR_LEN(""));
 	buffer_append_int(b, srv->conns->used);
@@ -469,8 +467,10 @@ static handler_t mod_status_handle_server_status_html(server *srv, connection *c
 
 		if (CON_STATE_READ == c->state && !buffer_string_is_empty(c->request.orig_uri)) {
 			state = "k";
+			++cstates[CON_STATE_CLOSE+2];
 		} else {
 			state = connection_get_short_state(c->state);
+			++cstates[(c->state <= CON_STATE_CLOSE ? c->state : CON_STATE_CLOSE+1)];
 		}
 
 		buffer_append_string_len(b, state, 1);
@@ -479,6 +479,22 @@ static handler_t mod_status_handle_server_status_html(server *srv, connection *c
 			buffer_append_string_len(b, CONST_STR_LEN("\n"));
 		}
 	}
+	buffer_append_string_len(b, CONST_STR_LEN("\n\n\n"));
+	buffer_append_string_len(b, CONST_STR_LEN("\n"));
+	for (j = 0; j < CON_STATE_CLOSE+2; ++j) {
+		/*(skip "unknown" state if there are none; there should not be any unknown)*/
+		if (0 == cstates[j] && j == CON_STATE_CLOSE+1) continue;
+		buffer_append_string_len(b, CONST_STR_LEN("\n"));
+	}
+	buffer_append_string_len(b, CONST_STR_LEN("
")); + buffer_append_int(b, cstates[CON_STATE_CLOSE+2]); + buffer_append_string_len(b, CONST_STR_LEN("  k = keep-alive
")); + buffer_append_int(b, cstates[j]); + buffer_append_string_len(b, CONST_STR_LEN("  ")); + buffer_append_string_len(b, connection_get_short_state(j), 1); + buffer_append_string_len(b, CONST_STR_LEN(" = ")); + buffer_append_string(b, connection_get_state(j)); + buffer_append_string_len(b, CONST_STR_LEN("
")); buffer_append_string_len(b, CONST_STR_LEN("\n

\n

Connections

\n"));