[PATCH] ngx_gzip might hang the request for slow downstreams
Yichun Zhang (agentzh)
agentzh at gmail.com
Mon Oct 28 22:37:44 UTC 2013
Hello!
On Mon, Oct 28, 2013 at 2:02 PM, Maxim Dounin wrote:
>>
>> - if (ctx->nomem) {
>> + if (ctx->nomem || in == NULL) {
>>
>> /* flush busy buffers */
>
> Is the same problem exists in the gunzip filter, which has very
> similar code?
Yes. I've reproduced the request hang in the gunzip filter module as
well, with the following minimal test case:
https://github.com/chaoslawful/lua-nginx-module/commit/594f55b
> Is a similar patch needed there?
>
Yes. I can confirm that a similar patch fixes the hang on my side.
> And, BTW, do you care to provide a Mercurial changeset, as
> suggested by nginx.org/en/docs/contributing_changes.html? It's
> not something required, but will make sure your name will be kept
> in history as a proper person to blame. :)
>
Here we go:
# HG changeset patch
# User Yichun Zhang <agentzh at gmail.com>
# Date 1382997696 25200
# Branch gzip-flush
# Node ID 8985d6cc9a4334e954909c130e6204c6fc673d7e
# Parent e6a1623f87bc96d5ec62b6d77356aa47dbc60756
Flush pending data when incoming chain is NULL in gzip and gunzip modules
diff -r e6a1623f87bc -r 8985d6cc9a43
src/http/modules/ngx_http_gunzip_filter_module.c
--- a/src/http/modules/ngx_http_gunzip_filter_module.c Mon Oct 21
18:20:32 2013 +0800
+++ b/src/http/modules/ngx_http_gunzip_filter_module.c Mon Oct 28
15:01:36 2013 -0700
@@ -199,7 +199,7 @@
}
}
- if (ctx->nomem) {
+ if (ctx->nomem || in == NULL) {
/* flush busy buffers */
diff -r e6a1623f87bc -r 8985d6cc9a43
src/http/modules/ngx_http_gzip_filter_module.c
--- a/src/http/modules/ngx_http_gzip_filter_module.c Mon Oct 21
18:20:32 2013 +0800
+++ b/src/http/modules/ngx_http_gzip_filter_module.c Mon Oct 28
15:01:36 2013 -0700
@@ -372,7 +372,7 @@
r->connection->buffered |= NGX_HTTP_GZIP_BUFFERED;
}
- if (ctx->nomem) {
+ if (ctx->nomem || in == NULL) {
/* flush busy buffers */
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gzip_gunzip_flush_bug.patch
Type: text/x-patch
Size: 1117 bytes
Desc: not available
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20131028/9b1170b3/attachment-0001.bin>
More information about the nginx-devel
mailing list