]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[BUG]: Restore clearing t->logs.bytes
authorKrzysztof Piotr Oledzki <ole@ans.pl>
Sun, 20 Jan 2008 22:27:02 +0000 (23:27 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 22 Jan 2008 09:26:27 +0000 (10:26 +0100)
Commit 8b3977ffe36190e45fb974bf813bfbd935ac99a1 removed "t->logs.bytes_in = 0;"
but instead it should change it into "t->logs.bytes_out = 0;" as since
583bc966064e248771e75c253dddec7351afd8a2 counters are incremented not set.

It should be incremented in session_process_counters while sending data to a
client:
        bytes = s->rep->total - s->logs.bytes_out;
        s->logs.bytes_out = s->rep->total;

However, if we increment (set) s->logs.bytes_out while processing
"logasap", statistics get wrong values added for headers: 0 or even
negative if haproxy adds some headers itself.

To test it, please enable logasap and download one empty file and look at
stats. Without my fix information available on that page are invalid, for
example:

# pxname,svname,qcur,qmax,scur,smax,slim,stot,bin,bout,dreq,dresp,ereq,econ,eresp,wretr,wredis,status,weight,act,bck,chkfail,chkdown,lastchg,downtime,qlimit,pid,iid,sid,throttle,lbtot,
www,b,0,0,0,1,,1,24,-92,,0,,0,0,0,,UP,1,1,0,0,0,3121,0,,1,2,1,,1,
www,BACKEND,0,0,0,1,0,1,24,-92,0,0,,0,0,0,0,UP,1,1,0,,0,3121,0,,1,2,0,,1,

src/proto_http.c

index 69864779350d96368a1c2bc752f4e4b0b1d563f7..5977f8d4b14b0fb60d994a2273f1311eb5b46555 100644 (file)
@@ -3102,7 +3102,9 @@ int process_srv(struct session *t)
                }
 #endif
                /* if the user wants to log as soon as possible, without counting
-                  bytes from the server, then this is the right moment. */
+                * bytes from the server, then this is the right moment. We have
+                * to temporarily assign bytes_out to log what we currently have.
+                */
                if (t->fe->to_log && !(t->logs.logwait & LW_BYTES)) {
                        t->logs.t_close = t->logs.t_data; /* to get a valid end date */
                        t->logs.bytes_out = txn->rsp.eoh;
@@ -3110,6 +3112,7 @@ int process_srv(struct session *t)
                                http_sess_log(t);
                        else
                                tcp_sess_log(t);
+                       t->logs.bytes_out = 0;
                }
 
                /* Note: we must not try to cheat by jumping directly to DATA,