void counters_fe_reset(struct fe_counters *counters);
void counters_be_reset(struct be_counters *counters);
+/* Reset only the max/peak fields of <counters>, leaving cumulative counters
+ * intact. This is what the plain "clear counters" command does (as opposed to
+ * "clear counters all" which performs a full reset via counters_*_reset()).
+ * The max fields are interleaved with live cumulative fields, so they are
+ * cleared individually rather than with a blanket memset.
+ */
+void counters_fe_reset_max(struct fe_counters *counters);
+void counters_be_reset_max(struct be_counters *counters);
+
/* time oriented helper: get last time (relative to current time) on a given
* <scounter> array, for <elem> member (one member per thread group) which is
* assumed to be unsigned long type.
memset((char *)counters + sizeof(counters->shared), 0,
sizeof(*counters) - sizeof(counters->shared));
}
+
+/* Reset only the max/peak gauges of a frontend/listener <counters> struct,
+ * leaving cumulative counters intact. Used by the plain "clear counters"
+ * command (as opposed to "clear counters all" which resets everything via
+ * counters_fe_reset()).
+ */
+void counters_fe_reset_max(struct fe_counters *counters)
+{
+ if (!counters)
+ return;
+
+ counters->conn_max = 0;
+ counters->cps_max = 0;
+ counters->sps_max = 0;
+ counters->p.http.rps_max = 0;
+}
+
+/* Reset only the max/peak gauges of a backend/server <counters> struct,
+ * leaving cumulative counters intact. See counters_fe_reset_max().
+ *
+ * Note: this clears the union of all max gauges present in the struct. The
+ * previous inline code cleared slightly different subsets for backends and
+ * servers (backends left cur_sess_max untouched, servers left conn_max /
+ * cps_max / rps_max untouched); those were latent gaps, so plain "clear
+ * counters" now consistently resets every peak gauge for both.
+ */
+void counters_be_reset_max(struct be_counters *counters)
+{
+ if (!counters)
+ return;
+
+ counters->conn_max = 0;
+ counters->cps_max = 0;
+ counters->sps_max = 0;
+ counters->nbpend_max = 0;
+ counters->cur_sess_max = 0;
+ counters->qtime_max = 0;
+ counters->ctime_max = 0;
+ counters->dtime_max = 0;
+ counters->ttime_max = 0;
+ counters->p.http.rps_max = 0;
+}
counters_fe_reset(&px->fe_counters);
}
else {
- px->be_counters.conn_max = 0;
- px->be_counters.p.http.rps_max = 0;
- px->be_counters.sps_max = 0;
- px->be_counters.cps_max = 0;
- px->be_counters.nbpend_max = 0;
- px->be_counters.qtime_max = 0;
- px->be_counters.ctime_max = 0;
- px->be_counters.dtime_max = 0;
- px->be_counters.ttime_max = 0;
-
- px->fe_counters.conn_max = 0;
- px->fe_counters.p.http.rps_max = 0;
- px->fe_counters.sps_max = 0;
- px->fe_counters.cps_max = 0;
+ counters_be_reset_max(&px->be_counters);
+ counters_fe_reset_max(&px->fe_counters);
}
list_for_each_entry(sv, &px->servers, el_px) {
if (clrall)
counters_be_reset(&sv->counters);
- else {
- sv->counters.cur_sess_max = 0;
- sv->counters.nbpend_max = 0;
- sv->counters.sps_max = 0;
- sv->counters.qtime_max = 0;
- sv->counters.ctime_max = 0;
- sv->counters.dtime_max = 0;
- sv->counters.ttime_max = 0;
- }
+ else
+ counters_be_reset_max(&sv->counters);
}
list_for_each_entry(li, &px->conf.listeners, by_fe)
if (clrall)
counters_fe_reset(li->counters);
else
- li->counters->conn_max = 0;
+ counters_fe_reset_max(li->counters);
}
}