]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: servers: fix last_sess date calculation
authorWilly Tarreau <w@1wt.eu>
Thu, 23 Apr 2026 09:24:22 +0000 (11:24 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 23 Apr 2026 09:55:45 +0000 (11:55 +0200)
In 3.4-dev8, commit e264523112 ("MINOR: servers: Don't update last_sess
if it did not change") adjusted the last_sess date to avoid writing to
the same cache line all the time, however a typo makes it pick the wrong
second because it uses now_ms instead of now_ns (so the date would roughly
change every 12 days).

No backport needed.

include/haproxy/server.h

index 6bdd823f229ff16e23aa3af92a7280f0fa099a06..5ffc06880f1eda342a4069db03b0501bcafeeed6 100644 (file)
@@ -221,7 +221,7 @@ static inline void srv_inc_sess_ctr(struct server *s)
 static inline void srv_set_sess_last(struct server *s)
 {
        if (s->counters.shared.tg) {
-               uint now_sec = ns_to_sec(now_ms);
+               uint now_sec = ns_to_sec(now_ns);
 
                if (HA_ATOMIC_LOAD(&s->counters.shared.tg[tgid - 1]->last_sess) != now_sec)
                        HA_ATOMIC_STORE(&s->counters.shared.tg[tgid - 1]->last_sess, now_sec);