]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: stats: last session was not always set
authorWilly Tarreau <w@1wt.eu>
Tue, 22 Apr 2014 22:35:17 +0000 (00:35 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 22 Apr 2014 22:35:17 +0000 (00:35 +0200)
Cyril Bonté reported that the "lastsess" field of a stats-only backend
was never updated. In fact the same is true for any applet and anything
not a server. Also, lastsess was not updated for a server reusing its
connection for a new request.

Since the goal of this field is to report recent activity, it's better
to ensure that all accesses are reported. The call has been moved to
the code validating the session establishment instead, since everything
passes there.

src/backend.c
src/session.c

index 7d0be1b701dfe9f76c3d3461f11208a79bd6ffd1..e350af9af28228b5d51c4edf06f1ada8e432cf58 100644 (file)
@@ -674,7 +674,6 @@ int assign_server(struct session *s)
                        goto out;
                }
                else if (srv != prev_srv) {
-                       be_set_sess_last(s->be);
                        s->be->be_counters.cum_lbconn++;
                        srv->counters.cum_lbconn++;
                }
index 753d6cc9415177b60037248a3cd302cd8633a0cc..b37348967a3ec31c503c19c3436d7d528b429fab 100644 (file)
@@ -1180,6 +1180,7 @@ static void sess_prepare_conn_req(struct session *s, struct stream_interface *si
                s->logs.t_queue   = tv_ms_elapsed(&s->logs.tv_accept, &now);
                si->state         = SI_ST_EST;
                si->err_type      = SI_ET_NONE;
+               be_set_sess_last(s->be);
                /* let sess_establish() finish the job */
                return;
        }
@@ -1207,6 +1208,7 @@ static void sess_prepare_conn_req(struct session *s, struct stream_interface *si
        /* The server is assigned */
        s->logs.t_queue = tv_ms_elapsed(&s->logs.tv_accept, &now);
        si->state = SI_ST_ASS;
+       be_set_sess_last(s->be);
 }
 
 /* This stream analyser checks the switching rules and changes the backend