From b6d3a5cf7b76bc4da489b0c910637d02a0976ec9 Mon Sep 17 00:00:00 2001 From: "Yichun Zhang (agentzh)" Date: Fri, 31 Oct 2014 18:18:38 -0700 Subject: [PATCH] bugfix: applied the patch to fix a new regression in nginx 1.7.7's ngx_gzip and ngx_gunzip modules that could lead to request hang when the downstream is slow to write to. --- patches/nginx-1.7.7-gzip_gunzip_flush.patch | 40 +++++++++++++++++++++ util/mirror-tarballs | 7 ++++ 2 files changed, 47 insertions(+) create mode 100644 patches/nginx-1.7.7-gzip_gunzip_flush.patch diff --git a/patches/nginx-1.7.7-gzip_gunzip_flush.patch b/patches/nginx-1.7.7-gzip_gunzip_flush.patch new file mode 100644 index 0000000..c799963 --- /dev/null +++ b/patches/nginx-1.7.7-gzip_gunzip_flush.patch @@ -0,0 +1,40 @@ +# HG changeset patch +# User Yichun Zhang +# Date 1414804249 25200 +# Fri Oct 31 18:10:49 2014 -0700 +# Node ID 38a74e59f199edafad0a8caae5cfc921ab3302e8 +# Parent dff86e2246a53b0f4a61935cd5c8c0a0f66d0ca2 +Gzip Gunzip: always flush busy bufs when the incoming chain is NULL. + +After the system send buffer is full, NULL incoming chains are used to +flush pending output upon new write events. The current gzip and gunzip +filters may intercept NULL chains and keep the data stalling in +nginx's own send buffers, leading to request hanging (until send +timeout). + +This regression had appeared in nginx 1.7.7. + +diff -r dff86e2246a5 -r 38a74e59f199 src/http/modules/ngx_http_gunzip_filter_module.c +--- a/src/http/modules/ngx_http_gunzip_filter_module.c Mon Aug 25 13:41:31 2014 +0400 ++++ b/src/http/modules/ngx_http_gunzip_filter_module.c Fri Oct 31 18:10:49 2014 -0700 +@@ -200,7 +200,7 @@ ngx_http_gunzip_body_filter(ngx_http_req + } + } + +- if (ctx->nomem) { ++ if (ctx->nomem || in == NULL) { + + /* flush busy buffers */ + +diff -r dff86e2246a5 -r 38a74e59f199 src/http/modules/ngx_http_gzip_filter_module.c +--- a/src/http/modules/ngx_http_gzip_filter_module.c Mon Aug 25 13:41:31 2014 +0400 ++++ b/src/http/modules/ngx_http_gzip_filter_module.c Fri Oct 31 18:10:49 2014 -0700 +@@ -373,7 +373,7 @@ ngx_http_gzip_body_filter(ngx_http_reque + r->connection->buffered |= NGX_HTTP_GZIP_BUFFERED; + } + +- if (ctx->nomem) { ++ if (ctx->nomem || in == NULL) { + + /* flush busy buffers */ + diff --git a/util/mirror-tarballs b/util/mirror-tarballs index 109851f..7d7e9cc 100755 --- a/util/mirror-tarballs +++ b/util/mirror-tarballs @@ -277,6 +277,13 @@ if [ "$answer" = "N" ]; then echo fi +answer=`$root/util/ver-ge "$main_ver" 1.7.7` +if [ "$answer" = "Y" ]; then + echo "$info_txt applying the gzip_gunzip_flush patch for nginx" + patch -p1 < $root/patches/nginx-$main_ver-gzip_gunzip_flush.patch || exit 1 + echo +fi + rm -f *.patch || exit 1 cd .. || exit 1