From 7959a55e15566baa936b9880d216868e5390d8e5 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Mon, 23 Sep 2013 16:44:27 +0200 Subject: [PATCH] MINOR: http: compute response time before processing headers At the moment, HTTP response time is computed after response headers are processed. This can misleadingly assign to the server some heavy local processing (eg: regex), and also prevents response headers from passing information related to the response time (which can sometimes be useful for stats). Let's retrieve the reponse time before processing the headers instead. Note that in order to remain compatible with what was previously done, we disable the response time when we get a 502 or any bad response. This should probably be changed in 1.6 since it does not make sense anymore to lose this information. --- src/proto_http.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/proto_http.c b/src/proto_http.c index 6ab2676f6..5e10ba2bf 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -5700,6 +5700,9 @@ int http_process_res_common(struct session *t, struct channel *rep, int an_bit, } } + /* we want to have the response time before we start processing it */ + t->logs.t_data = tv_ms_elapsed(&t->logs.tv_accept, &now); + if (1) { /* * 3: we will have to evaluate the filters. @@ -5731,6 +5734,7 @@ int http_process_res_common(struct session *t, struct channel *rep, int an_bit, return_srv_prx_502: rep->analysers = 0; txn->status = 502; + t->logs.t_data = -1; /* was not a valid response */ rep->prod->flags |= SI_FL_NOLINGER; bi_erase(rep); stream_int_retnclose(rep->cons, http_error_message(t, HTTP_ERR_502)); @@ -5788,6 +5792,7 @@ int http_process_res_common(struct session *t, struct channel *rep, int an_bit, msg->next -= channel_forward(rep, msg->next); msg->msg_state = HTTP_MSG_RPBEFORE; txn->status = 0; + t->logs.t_data = -1; /* was not a response yet */ rep->analysers |= AN_RES_WAIT_HTTP | an_bit; return 1; } @@ -5960,8 +5965,6 @@ int http_process_res_common(struct session *t, struct channel *rep, int an_bit, * could. Let's switch to the DATA state. * ************************************************************/ - t->logs.t_data = tv_ms_elapsed(&t->logs.tv_accept, &now); - /* if the user wants to log as soon as possible, without counting * bytes from the server, then this is the right moment. We have * to temporarily assign bytes_out to log what we currently have.