[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".
This commit is contained in:
Willy Tarreau 2011-03-27 19:53:06 +02:00
parent 0b3a411543
commit 7b7a8e9d83
5 changed files with 13 additions and 9 deletions

View 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 */

View 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;

View File

@ -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>";

View 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;

View 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;