Welcome! Log In Create A New Profile

Advanced

[PATCH] Move calculation $upstream_response_time before send header to client.

catap+nginx@catap.ru
April 21, 2009 01:59PM
From: Kirill A. Korinskiy <catap@catap.ru>

Now calculation $upstream_response_time happen after send header to
client and we have a 0 ms response to not error (last) upstream.
---
src/http/ngx_http_upstream.c | 23 +++++++++++------------
1 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
index 7ae15cb..0771388 100644
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -1843,10 +1843,21 @@ ngx_http_upstream_send_response(ngx_http_request_t *r, ngx_http_upstream_t *u)
int tcp_nodelay;
ssize_t n;
ngx_int_t rc;
+ ngx_time_t *tp;
ngx_event_pipe_t *p;
ngx_connection_t *c;
ngx_http_core_loc_conf_t *clcf;

+ if (u->state && u->state->response_sec) {
+ tp = ngx_timeofday();
+ u->state->response_sec = tp->sec - u->state->response_sec;
+ u->state->response_msec = tp->msec - u->state->response_msec;
+
+ if (u->pipe) {
+ u->state->response_length = u->pipe->read_length;
+ }
+ }
+
rc = ngx_http_send_header(r);

if (rc == NGX_ERROR || rc > NGX_OK || r->post_action) {
@@ -2735,8 +2746,6 @@ static void
ngx_http_upstream_finalize_request(ngx_http_request_t *r,
ngx_http_upstream_t *u, ngx_int_t rc)
{
- ngx_time_t *tp;
-
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"finalize http upstream request: %i", rc);

@@ -2744,16 +2753,6 @@ ngx_http_upstream_finalize_request(ngx_http_request_t *r,
*u->cleanup = NULL;
}

- if (u->state && u->state->response_sec) {
- tp = ngx_timeofday();
- u->state->response_sec = tp->sec - u->state->response_sec;
- u->state->response_msec = tp->msec - u->state->response_msec;
-
- if (u->pipe) {
- u->state->response_length = u->pipe->read_length;
- }
- }
-
u->finalize_request(r, rc);

if (u->peer.free) {
--
1.6.2
Subject Author Posted

[PATCH] Move calculation $upstream_response_time before send header to client.

catap+nginx@catap.ru April 21, 2009 01:59PM

Re: [PATCH] Move calculation $upstream_response_time before send header to client.

Maxim Dounin April 22, 2009 04:30AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 181
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready