]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[BUG] log: retrieve the target from the session, not the SI
authorWilly Tarreau <w@1wt.eu>
Sun, 27 Mar 2011 17:53:06 +0000 (19:53 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 27 Mar 2011 17:53:06 +0000 (19:53 +0200)
Since we now have the copy of the target in the session, use it instead
of relying on the SI for it. The SI drops the target upon unregister()
so applets such as stats were logged as "NOSRV".

src/backend.c
src/dumpstats.c
src/log.c
src/peers.c
src/proto_http.c

index 397216d5a46de187ba5556dbee02c4a1ae272ed4..4b923a7e597bd0f8199771f9e5b4d7676ffd510d 100644 (file)
@@ -969,6 +969,7 @@ int connect_server(struct session *s)
         */
        stream_sock_prepare_interface(s->req->cons);
        s->req->cons->connect = tcp_connect_server;
+       /* the target was only on the session, assign it to the SI now */
        copy_target(&s->req->cons->target, &s->target);
 
        /* process the case where the server requires the PROXY protocol to be sent */
index 34f09014fee6eb77d34fab17c2a15afb415f6df2..6c12a1800cb4917902cb9b5a9c9e1c367fa2fdab 100644 (file)
@@ -107,6 +107,7 @@ int stats_accept(struct session *s)
 {
        /* we have a dedicated I/O handler for the stats */
        stream_int_register_handler(&s->si[1], &cli_applet);
+       copy_target(&s->target, &s->si[1].target); // for logging only
        s->si[1].applet.private = s;
        s->si[1].applet.st1 = 0;
        s->si[1].applet.st0 = STAT_CLI_INIT;
index f90ec90f6e1b0a6ce35b5000a9d86fb09c48b191..f70b38e8e175c5396c9528a78768f78299eb61f0 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -352,12 +352,12 @@ void tcp_sess_log(struct session *s)
 
        if (!(tolog & LW_SVID))
                svid = "-";
-       else switch (s->req->cons->target.type) {
+       else switch (s->target.type) {
        case TARG_TYPE_SERVER:
-               svid = s->req->cons->target.ptr.s->id;
+               svid = s->target.ptr.s->id;
                break;
        case TARG_TYPE_APPLET:
-               svid = s->req->cons->target.ptr.a->name;
+               svid = s->target.ptr.a->name;
                break;
        default:
                svid = "<NOSRV>";
index 739c09b05df4ebbdb591d9f68293894b54256c49..0274483402b4552420d582c3df468f3ea18cac08 100644 (file)
@@ -1078,6 +1078,7 @@ int peer_accept(struct session *s)
 {
         /* we have a dedicated I/O handler for the stats */
        stream_int_register_handler(&s->si[1], &peer_applet);
+       copy_target(&s->target, &s->si[1].target); // for logging only
        s->si[1].release = peer_session_release;
        s->si[1].applet.private = s;
        s->si[1].applet.st0 = PEER_SESSION_ACCEPT;
index ef6f46ea84a0807f272ec604fc6dd7b902f61d39..c00aced6cc92f645e21b62eb12a29a806a1cfd6a 100644 (file)
@@ -948,12 +948,12 @@ void http_sess_clflog(struct session *s)
 
        if (!(tolog & LW_SVID))
                svid = "-";
-       else switch (s->req->cons->target.type) {
+       else switch (s->target.type) {
        case TARG_TYPE_SERVER:
-               svid = s->req->cons->target.ptr.s->id;
+               svid = s->target.ptr.s->id;
                break;
        case TARG_TYPE_APPLET:
-               svid = s->req->cons->target.ptr.a->name;
+               svid = s->target.ptr.a->name;
                break;
        default:
                svid = "<NOSRV>";
@@ -1171,12 +1171,12 @@ void http_sess_log(struct session *s)
 
        if (!(tolog & LW_SVID))
                svid = "-";
-       else switch (s->req->cons->target.type) {
+       else switch (s->target.type) {
        case TARG_TYPE_SERVER:
-               svid = s->req->cons->target.ptr.s->id;
+               svid = s->target.ptr.s->id;
                break;
        case TARG_TYPE_APPLET:
-               svid = s->req->cons->target.ptr.a->name;
+               svid = s->target.ptr.a->name;
                break;
        default:
                svid = "<NOSRV>";
@@ -3278,6 +3278,7 @@ int http_process_req_common(struct session *s, struct buffer *req, int an_bit, s
                s->logs.tv_request = now;
                s->task->nice = -32; /* small boost for HTTP statistics */
                stream_int_register_handler(s->rep->prod, &http_stats_applet);
+               copy_target(&s->target, &s->rep->prod->target); // for logging only
                s->rep->prod->applet.private = s;
                s->rep->prod->applet.st0 = s->rep->prod->applet.st1 = 0;
                req->analysers = 0;