char flags; /* bit field PR_FL_* */
enum pr_mode mode; /* mode = PR_MODE_TCP, PR_MODE_HTTP, ... */
char cap; /* supported capabilities (PR_CAP_*) */
- /* 4-bytes hole */
+ unsigned long last_change; /* internal use only: last time the proxy state was changed */
struct list global_list; /* list member for global proxy list */
*/
void set_backend_down(struct proxy *be)
{
+ be->last_change = ns_to_sec(now_ns);
HA_ATOMIC_STORE(&be->be_counters.shared->tg[tgid - 1]->last_change, ns_to_sec(now_ns));
_HA_ATOMIC_INC(&be->be_counters.shared->tg[tgid - 1]->down_trans);
}
int be_downtime(struct proxy *px) {
- unsigned long last_change = COUNTERS_SHARED_LAST(px->be_counters.shared->tg, last_change);
-
- if (px->lbprm.tot_weight && last_change < ns_to_sec(now_ns)) // ignore negative time
+ if (px->lbprm.tot_weight && px->last_change < ns_to_sec(now_ns)) // ignore negative time
return px->down_time;
- return ns_to_sec(now_ns) - last_change + px->down_time;
+ return ns_to_sec(now_ns) - px->last_change + px->down_time;
}
/*
}
px->cap = cap;
+ px->last_change = ns_to_sec(now_ns);
if (name && !(cap & PR_CAP_INT))
proxy_store_name(px);
if (prev_srv_count && s->proxy->srv_bck == 0 && s->proxy->srv_act == 0)
set_backend_down(s->proxy); /* backend going down */
else if (!prev_srv_count && (s->proxy->srv_bck || s->proxy->srv_act)) {
- unsigned long last_change = COUNTERS_SHARED_LAST(s->proxy->be_counters.shared->tg, last_change);
+ unsigned long last_change = s->proxy->last_change;
/* backend was down and is back up again:
* no helper function, updating last_change and backend downtime stats
*/
if (last_change < ns_to_sec(now_ns)) // ignore negative times
s->proxy->down_time += ns_to_sec(now_ns) - last_change;
+ s->proxy->last_change = ns_to_sec(now_ns);
HA_ATOMIC_STORE(&s->proxy->be_counters.shared->tg[tgid - 1]->last_change, ns_to_sec(now_ns));
}
}