details: https://hg.nginx.org/njs/rev/0d15daffba9e
branches:
changeset: 1600:0d15daffba9e
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Wed Feb 10 14:03:11 2021 +0000
description:
Stream: fixed processing buffered data in body filter.
Previously, when data was proxied to upstream, it may be partially
written and is left in upstream connection buffer. Later, when
writing becomes possible again, the body filter is called but it
fails to call the next filter in the chain. This resulted in hanging
connection.
The fix is to take the buffered data in upstream connection into account.
This fixes #368 issue on Github.
diffstat:
nginx/ngx_stream_js_module.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diffs (28 lines):
diff -r a41cd80e2f3a -r 0d15daffba9e nginx/ngx_stream_js_module.c
--- a/nginx/ngx_stream_js_module.c Mon Feb 01 02:16:51 2021 +0100
+++ b/nginx/ngx_stream_js_module.c Wed Feb 10 14:03:11 2021 +0000
@@ -506,7 +506,7 @@ ngx_stream_js_body_filter(ngx_stream_ses
njs_int_t ret;
ngx_int_t rc;
ngx_chain_t *out, *cl;
- ngx_connection_t *c;
+ ngx_connection_t *c, *dst;
ngx_stream_js_ev_t *event;
ngx_stream_js_ctx_t *ctx;
ngx_stream_js_srv_conf_t *jscf;
@@ -580,7 +580,14 @@ ngx_stream_js_body_filter(ngx_stream_ses
*ctx->last_out = NULL;
- if (out != NULL || c->buffered) {
+ if (from_upstream) {
+ dst = c;
+
+ } else {
+ dst = s->upstream ? s->upstream->peer.connection : NULL;
+ }
+
+ if (out != NULL || dst == NULL || dst->buffered) {
rc = ngx_stream_next_filter(s, out, from_upstream);
ngx_chain_update_chains(c->pool, &ctx->free, &ctx->busy, &out,
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel