Skip to content

Commit 92de4ff

Browse files
committed
statistics: Improve the stat group parser
Although we break backwards-compatibility, we actually fix the logic to be closer to what users would expect. For example, a "method:register:auth" statistic is more naturally interpreted as: { "group": "method", "stat": "register:auth" } (new behavior) rather than: { "group": "method:register", "stat": "auth" } (old behavior). (cherry picked from commit 4d028f7)
1 parent 6cc56d2 commit 92de4ff

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

modules/statistics/stats_funcs.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,11 @@ int register_all_mod_stats(void)
116116

117117
void parse_groupname(const str *in, str *out_grp, str *out_name)
118118
{
119-
char *p;
119+
char *p, *lim = in->s + in->len;
120120

121-
for (p = in->s + in->len - 1; *p != STAT_GROUP_DELIM && p > in->s; p--) {}
122-
if (p == in->s) {
121+
for (p = in->s; *p != STAT_GROUP_DELIM && p < lim; p++) {}
122+
123+
if (p >= lim) {
123124
out_grp->s = NULL;
124125
out_grp->len = 0;
125126
*out_name = *in;

0 commit comments

Comments
 (0)