From: Willy Tarreau Date: Sun, 27 Mar 2011 17:53:06 +0000 (+0200) Subject: [BUG] log: retrieve the target from the session, not the SI X-Git-Tag: v1.5-dev8~257 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7b7a8e9d8335e76ca791d5d0eee3e6e381a8e15f;p=thirdparty%2Fhaproxy.git [BUG] log: retrieve the target from the session, not the SI 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". --- diff --git a/src/backend.c b/src/backend.c index 397216d5a4..4b923a7e59 100644 --- a/src/backend.c +++ b/src/backend.c @@ -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 */ diff --git a/src/dumpstats.c b/src/dumpstats.c index 34f09014fe..6c12a1800c 100644 --- a/src/dumpstats.c +++ b/src/dumpstats.c @@ -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; diff --git a/src/log.c b/src/log.c index f90ec90f6e..f70b38e8e1 100644 --- 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 = ""; diff --git a/src/peers.c b/src/peers.c index 739c09b05d..0274483402 100644 --- a/src/peers.c +++ b/src/peers.c @@ -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; diff --git a/src/proto_http.c b/src/proto_http.c index ef6f46ea84..c00aced6cc 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -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 = ""; @@ -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 = ""; @@ -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;