[nginx] Upstream: don't keep connections on early responses (tic...
Maxim Dounin
mdounin at mdounin.ru
Thu Dec 17 14:09:21 UTC 2015
details: http://hg.nginx.org/nginx/rev/78b4e10b4367
branches:
changeset: 6332:78b4e10b4367
user: Maxim Dounin <mdounin at mdounin.ru>
date: Thu Dec 17 16:39:15 2015 +0300
description:
Upstream: don't keep connections on early responses (ticket #669).
diffstat:
src/http/modules/ngx_http_upstream_keepalive_module.c | 4 ++++
src/http/ngx_http_upstream.c | 3 +++
src/http/ngx_http_upstream.h | 1 +
3 files changed, 8 insertions(+), 0 deletions(-)
diffs (45 lines):
diff --git a/src/http/modules/ngx_http_upstream_keepalive_module.c b/src/http/modules/ngx_http_upstream_keepalive_module.c
--- a/src/http/modules/ngx_http_upstream_keepalive_module.c
+++ b/src/http/modules/ngx_http_upstream_keepalive_module.c
@@ -302,6 +302,10 @@ ngx_http_upstream_free_keepalive_peer(ng
goto invalid;
}
+ if (!u->request_body_sent) {
+ goto invalid;
+ }
+
if (ngx_terminate || ngx_exiting) {
goto invalid;
}
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -1441,6 +1441,7 @@ ngx_http_upstream_connect(ngx_http_reque
}
u->request_sent = 0;
+ u->request_body_sent = 0;
if (rc == NGX_AGAIN) {
ngx_add_timer(c->write, u->conf->connect_timeout);
@@ -1825,6 +1826,8 @@ ngx_http_upstream_send_request(ngx_http_
/* rc == NGX_OK */
+ u->request_body_sent = 1;
+
if (c->write->timer_set) {
ngx_del_timer(c->write);
}
diff --git a/src/http/ngx_http_upstream.h b/src/http/ngx_http_upstream.h
--- a/src/http/ngx_http_upstream.h
+++ b/src/http/ngx_http_upstream.h
@@ -370,6 +370,7 @@ struct ngx_http_upstream_s {
unsigned upgrade:1;
unsigned request_sent:1;
+ unsigned request_body_sent:1;
unsigned header_sent:1;
};
More information about the nginx-devel
mailing list