Mercurial > hg > nginx
comparison src/http/ngx_http_upstream.c @ 7231:22f7bdbd96d3
Upstream: u->request_body_blocked flag.
The flag indicates whether last ngx_output_chain() returned NGX_AGAIN
or not. If the flag is set, we arm the u->conf->send_timeout timer.
The flag complements c->write->ready test, and allows to stop sending
the request body in an output filter due to protocol-specific flow
control.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Sat, 17 Mar 2018 23:04:22 +0300 |
parents | 098bbd076a2d |
children | a7ed15573ae9 |
comparison
equal
deleted
inserted
replaced
7230:098bbd076a2d | 7231:22f7bdbd96d3 |
---|---|
1614 r->request_body->buf->tag = u->output.tag; | 1614 r->request_body->buf->tag = u->output.tag; |
1615 } | 1615 } |
1616 | 1616 |
1617 u->request_sent = 0; | 1617 u->request_sent = 0; |
1618 u->request_body_sent = 0; | 1618 u->request_body_sent = 0; |
1619 u->request_body_blocked = 0; | |
1619 | 1620 |
1620 if (rc == NGX_AGAIN) { | 1621 if (rc == NGX_AGAIN) { |
1621 ngx_add_timer(c->write, u->conf->connect_timeout); | 1622 ngx_add_timer(c->write, u->conf->connect_timeout); |
1622 return; | 1623 return; |
1623 } | 1624 } |
1992 ngx_http_upstream_finalize_request(r, u, rc); | 1993 ngx_http_upstream_finalize_request(r, u, rc); |
1993 return; | 1994 return; |
1994 } | 1995 } |
1995 | 1996 |
1996 if (rc == NGX_AGAIN) { | 1997 if (rc == NGX_AGAIN) { |
1997 if (!c->write->ready) { | 1998 if (!c->write->ready || u->request_body_blocked) { |
1998 ngx_add_timer(c->write, u->conf->send_timeout); | 1999 ngx_add_timer(c->write, u->conf->send_timeout); |
1999 | 2000 |
2000 } else if (c->write->timer_set) { | 2001 } else if (c->write->timer_set) { |
2001 ngx_del_timer(c->write); | 2002 ngx_del_timer(c->write); |
2002 } | 2003 } |
2069 | 2070 |
2070 } else { | 2071 } else { |
2071 out = NULL; | 2072 out = NULL; |
2072 } | 2073 } |
2073 | 2074 |
2074 return ngx_output_chain(&u->output, out); | 2075 rc = ngx_output_chain(&u->output, out); |
2076 | |
2077 if (rc == NGX_AGAIN) { | |
2078 u->request_body_blocked = 1; | |
2079 | |
2080 } else { | |
2081 u->request_body_blocked = 0; | |
2082 } | |
2083 | |
2084 return rc; | |
2075 } | 2085 } |
2076 | 2086 |
2077 if (!u->request_sent) { | 2087 if (!u->request_sent) { |
2078 u->request_sent = 1; | 2088 u->request_sent = 1; |
2079 out = u->request_bufs; | 2089 out = u->request_bufs; |
2108 | 2118 |
2109 while (out) { | 2119 while (out) { |
2110 ln = out; | 2120 ln = out; |
2111 out = out->next; | 2121 out = out->next; |
2112 ngx_free_chain(r->pool, ln); | 2122 ngx_free_chain(r->pool, ln); |
2123 } | |
2124 | |
2125 if (rc == NGX_AGAIN) { | |
2126 u->request_body_blocked = 1; | |
2127 | |
2128 } else { | |
2129 u->request_body_blocked = 0; | |
2113 } | 2130 } |
2114 | 2131 |
2115 if (rc == NGX_OK && !r->reading_body) { | 2132 if (rc == NGX_OK && !r->reading_body) { |
2116 break; | 2133 break; |
2117 } | 2134 } |