Permalink
Browse files

initial work for migrating to the 1.0.8.1 release; applied the variab…

…le-header-ignore-no-hash patch.
  • Loading branch information...
agentzh committed Oct 7, 2011
1 parent ee9cf6c commit 23506e83289be6e2f80596f95f20f9e0d67f5ea1
@@ -0,0 +1,69 @@
+# HG changeset patch
+# User Maxim Dounin <mdounin@mdounin.ru>
+# Date 1315324342 -14400
+# Node ID 4cf0af103bc382a78f894302d1706929a79df4bb
+# Parent d603ce98fada855f0100b422b7b5672fd22fabea
+Gzip filter: handle empty flush buffers.
+
+Empty flush buffers are legitimate and may happen e.g. due to $r->flush()
+calls in embedded perl. If there are no data buffered in zlib deflate()
+will return Z_BUF_ERROR (i.e. no progress possible) without adding anything
+to output. Don't treat Z_BUF_ERROR as fatal and correctly send empty flush
+buffer if we have no data in output at all.
+
+See this thread for details:
+http://mailman.nginx.org/pipermail/nginx/2010-November/023693.html
+
+diff --git a/src/http/modules/ngx_http_gzip_filter_module.c b/src/http/modules/ngx_http_gzip_filter_module.c
+--- a/src/http/modules/ngx_http_gzip_filter_module.c
++++ b/src/http/modules/ngx_http_gzip_filter_module.c
+@@ -758,6 +758,7 @@ static ngx_int_t
+ ngx_http_gzip_filter_deflate(ngx_http_request_t *r, ngx_http_gzip_ctx_t *ctx)
+ {
+ int rc;
++ ngx_buf_t *b;
+ ngx_chain_t *cl;
+ ngx_http_gzip_conf_t *conf;
+
+@@ -769,7 +770,7 @@ ngx_http_gzip_filter_deflate(ngx_http_re
+
+ rc = deflate(&ctx->zstream, ctx->flush);
+
+- if (rc != Z_OK && rc != Z_STREAM_END) {
++ if (rc != Z_OK && rc != Z_STREAM_END && rc != Z_BUF_ERROR) {
+ ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
+ "deflate() failed: %d, %d", ctx->flush, rc);
+ return NGX_ERROR;
+@@ -818,8 +819,6 @@ ngx_http_gzip_filter_deflate(ngx_http_re
+
+ if (ctx->flush == Z_SYNC_FLUSH) {
+
+- ctx->zstream.avail_out = 0;
+- ctx->out_buf->flush = 1;
+ ctx->flush = Z_NO_FLUSH;
+
+ cl = ngx_alloc_chain_link(r->pool);
+@@ -827,7 +826,22 @@ ngx_http_gzip_filter_deflate(ngx_http_re
+ return NGX_ERROR;
+ }
+
+- cl->buf = ctx->out_buf;
++ b = ctx->out_buf;
++
++ if (ngx_buf_size(b) == 0) {
++
++ b = ngx_calloc_buf(ctx->request->pool);
++ if (b == NULL) {
++ return NGX_ERROR;
++ }
++
++ } else {
++ ctx->zstream.avail_out = 0;
++ }
++
++ b->flush = 1;
++
++ cl->buf = b;
+ cl->next = NULL;
+ *ctx->last_out = cl;
+ ctx->last_out = &cl->next;
@@ -0,0 +1,24 @@
+diff -ur nginx-1.0.8/auto/cc/gcc nginx-1.0.8-patched/auto/cc/gcc
+--- nginx-1.0.8/auto/cc/gcc 2011-06-27 19:53:00.205737804 +0800
++++ nginx-1.0.8-patched/auto/cc/gcc 2011-06-27 19:53:13.837741087 +0800
+@@ -169,7 +169,7 @@
+
+
+ # stop on warning
+-CFLAGS="$CFLAGS -Werror"
++#CFLAGS="$CFLAGS -Werror"
+
+ # debug
+ CFLAGS="$CFLAGS -g"
+diff -ur nginx-1.0.8/auto/cc/icc nginx-1.0.8-patched/auto/cc/icc
+--- nginx-1.0.8/auto/cc/icc 2011-06-27 19:52:56.370157068 +0800
++++ nginx-1.0.8-patched/auto/cc/icc 2011-06-27 19:53:19.508916811 +0800
+@@ -139,7 +139,7 @@
+ esac
+
+ # stop on warning
+-CFLAGS="$CFLAGS -Werror"
++#CFLAGS="$CFLAGS -Werror"
+
+ # debug
+ CFLAGS="$CFLAGS -g"
@@ -0,0 +1,90 @@
+--- nginx-1.0.8/src/http/ngx_http_core_module.c 2010-12-14 18:38:42.000000000 +0800
++++ nginx-1.0.8-patched/src/http/ngx_http_core_module.c 2011-01-30 19:24:34.956354518 +0800
+@@ -57,6 +57,8 @@
+ void *conf);
+ static char *ngx_http_core_error_page(ngx_conf_t *cf, ngx_command_t *cmd,
+ void *conf);
++static char *ngx_http_core_no_error_pages(ngx_conf_t *cf, ngx_command_t *cmd,
++ void *conf);
+ static char *ngx_http_core_try_files(ngx_conf_t *cf, ngx_command_t *cmd,
+ void *conf);
+ static char *ngx_http_core_open_file_cache(ngx_conf_t *cf, ngx_command_t *cmd,
+@@ -614,6 +616,14 @@
+ 0,
+ NULL },
+
++ { ngx_string("no_error_pages"),
++ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
++ |NGX_CONF_NOARGS,
++ ngx_http_core_no_error_pages,
++ NGX_HTTP_LOC_CONF_OFFSET,
++ 0,
++ NULL },
++
+ { ngx_string("try_files"),
+ NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_2MORE,
+ ngx_http_core_try_files,
+@@ -3052,7 +3062,6 @@
+ * clcf->types = NULL;
+ * clcf->default_type = { 0, NULL };
+ * clcf->error_log = NULL;
+- * clcf->error_pages = NULL;
+ * clcf->try_files = NULL;
+ * clcf->client_body_path = NULL;
+ * clcf->regex = NULL;
+@@ -3062,6 +3071,7 @@
+ * clcf->gzip_proxied = 0;
+ */
+
++ clcf->error_pages = NGX_CONF_UNSET_PTR;
+ clcf->client_max_body_size = NGX_CONF_UNSET;
+ clcf->client_body_buffer_size = NGX_CONF_UNSET_SIZE;
+ clcf->client_body_timeout = NGX_CONF_UNSET_MSEC;
+@@ -3250,9 +3260,7 @@
+ }
+ }
+
+- if (conf->error_pages == NULL && prev->error_pages) {
+- conf->error_pages = prev->error_pages;
+- }
++ ngx_conf_merge_ptr_value(conf->error_pages, prev->error_pages, NULL);
+
+ ngx_conf_merge_str_value(conf->default_type,
+ prev->default_type, "text/plain");
+@@ -3988,6 +3996,10 @@
+ ngx_http_compile_complex_value_t ccv;
+
+ if (clcf->error_pages == NULL) {
++ return "conflicts with \"no_error_pages\"";
++ }
++
++ if (clcf->error_pages == NGX_CONF_UNSET_PTR) {
+ clcf->error_pages = ngx_array_create(cf->pool, 4,
+ sizeof(ngx_http_err_page_t));
+ if (clcf->error_pages == NULL) {
+@@ -4095,6 +4107,25 @@
+
+
+ static char *
++ngx_http_core_no_error_pages(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
++{
++ ngx_http_core_loc_conf_t *clcf = conf;
++
++ if (clcf->error_pages == NULL) {
++ return "is duplicate";
++ }
++
++ if (clcf->error_pages != NGX_CONF_UNSET_PTR) {
++ return "conflicts with \"error_page\"";
++ }
++
++ clcf->error_pages = NULL;
++
++ return NGX_CONF_OK;
++}
++
++
++static char *
+ ngx_http_core_try_files(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
+ {
+ ngx_http_core_loc_conf_t *clcf = conf;
Oops, something went wrong.

0 comments on commit 23506e8

Please sign in to comment.