Commit 0672a5e5 authored by Martin Blix Grydeland's avatar Martin Blix Grydeland Committed by Lasse Karstensen

Use n + hist_buckets as hit flag in varnishhist bucket history

Because -0 == +0, the use of negative numbers as a distinction between
hits and misses in the recorded bucket history fails when there are
entries of index 0.

Fixes: #1623
parent 39349f4f
......@@ -193,7 +193,8 @@ static int /*__match_proto__ (VSLQ_dispatch_f)*/
accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[],
void *priv)
{
int i, j, tag, skip, match, hit;
int i, tag, skip, match, hit;
unsigned u;
double value;
struct VSL_transaction *tr;
......@@ -259,13 +260,15 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[],
/* phase out old data */
if (nhist == HIST_N) {
j = rr_hist[next_hist];
if (j < 0) {
assert(bucket_miss[-j] > 0);
bucket_miss[-j]--;
u = rr_hist[next_hist];
if (u >= hist_buckets) {
u -= hist_buckets;
assert(u < hist_buckets);
assert(bucket_hit[u] > 0);
bucket_hit[u]--;
} else {
assert(bucket_hit[j] > 0);
bucket_hit[j]--;
assert(bucket_miss[u] > 0);
bucket_miss[u]--;
}
} else {
++nhist;
......@@ -274,10 +277,10 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[],
/* phase in new data */
if (hit) {
bucket_hit[i]++;
rr_hist[next_hist] = i;
rr_hist[next_hist] = i + hist_buckets;
} else {
bucket_miss[i]++;
rr_hist[next_hist] = -i;
rr_hist[next_hist] = i;
}
if (++next_hist == HIST_N) {
next_hist = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment