Permalink
Browse files

upgraded the nginx core to 1.0.10.

  • Loading branch information...
1 parent 7215210 commit 10d70ab81a65c6e94c1820e48245171caa43ee3d @agentzh agentzh committed Nov 16, 2011
@@ -0,0 +1,117 @@
+diff -ur nginx-1.0.10/src/http/ngx_http_request_body.c nginx-1.0.10-patched/src/http/ngx_http_request_body.c
+--- nginx-1.0.10/src/http/ngx_http_request_body.c 2011-09-30 22:36:19.000000000 +0800
++++ nginx-1.0.10-patched/src/http/ngx_http_request_body.c 2011-10-21 21:54:08.460350482 +0800
+@@ -38,7 +38,7 @@
+
+ r->main->count++;
+
+- if (r->request_body || r->discard_body) {
++ if (r->request_body || r->discard_body || r->content_length_n == 0) {
+ post_handler(r);
+ return NGX_OK;
+ }
+@@ -440,7 +440,7 @@
+ ssize_t size;
+ ngx_event_t *rev;
+
+- if (r != r->main || r->discard_body) {
++ if (r != r->main || r->discard_body || r->content_length_n == 0) {
+ return NGX_OK;
+ }
+
+@@ -456,20 +456,22 @@
+ ngx_del_timer(rev);
+ }
+
+- if (r->headers_in.content_length_n <= 0 || r->request_body) {
++ r->content_length_n = r->headers_in.content_length_n;
++
++ if (r->content_length_n <= 0 || r->request_body) {
+ return NGX_OK;
+ }
+
+ size = r->header_in->last - r->header_in->pos;
+
+ if (size) {
+- if (r->headers_in.content_length_n > size) {
++ if (r->content_length_n > size) {
+ r->header_in->pos += size;
+- r->headers_in.content_length_n -= size;
++ r->content_length_n -= size;
+
+ } else {
+- r->header_in->pos += (size_t) r->headers_in.content_length_n;
+- r->headers_in.content_length_n = 0;
++ r->header_in->pos += (size_t) r->content_length_n;
++ r->content_length_n = 0;
+ return NGX_OK;
+ }
+ }
+@@ -568,7 +570,7 @@
+ "http read discarded body");
+
+ for ( ;; ) {
+- if (r->headers_in.content_length_n == 0) {
++ if (r->content_length_n == 0) {
+ r->read_event_handler = ngx_http_block_reading;
+ return NGX_OK;
+ }
+@@ -577,9 +579,9 @@
+ return NGX_AGAIN;
+ }
+
+- size = (r->headers_in.content_length_n > NGX_HTTP_DISCARD_BUFFER_SIZE) ?
++ size = (r->content_length_n > NGX_HTTP_DISCARD_BUFFER_SIZE) ?
+ NGX_HTTP_DISCARD_BUFFER_SIZE:
+- (size_t) r->headers_in.content_length_n;
++ (size_t) r->content_length_n;
+
+ n = r->connection->recv(r->connection, buffer, size);
+
+@@ -596,7 +598,7 @@
+ return NGX_OK;
+ }
+
+- r->headers_in.content_length_n -= n;
++ r->content_length_n -= n;
+ }
+ }
+
+Only in nginx-1.0.10-patched/src/http: ngx_http_request_body.c~
+diff -ur nginx-1.0.10/src/http/ngx_http_request.c nginx-1.0.10-patched/src/http/ngx_http_request.c
+--- nginx-1.0.10/src/http/ngx_http_request.c 2011-09-30 22:36:19.000000000 +0800
++++ nginx-1.0.10-patched/src/http/ngx_http_request.c 2011-10-21 19:06:38.404350692 +0800
+@@ -286,6 +286,8 @@
+
+ r->pipeline = hc->pipeline;
+
++ r->content_length_n = -1;
++
+ if (hc->nbusy) {
+ r->header_in = hc->busy[0];
+ }
+@@ -297,6 +299,8 @@
+ return;
+ }
+
++ r->content_length_n = -1;
++
+ hc->request = r;
+ }
+
+Only in nginx-1.0.10-patched/src/http: ngx_http_request.c~
+diff -ur nginx-1.0.10/src/http/ngx_http_request.h nginx-1.0.10-patched/src/http/ngx_http_request.h
+--- nginx-1.0.10/src/http/ngx_http_request.h 2011-08-29 18:39:23.000000000 +0800
++++ nginx-1.0.10-patched/src/http/ngx_http_request.h 2011-10-21 17:26:13.203807584 +0800
+@@ -366,6 +366,9 @@
+ ngx_pool_t *pool;
+ ngx_buf_t *header_in;
+
++ off_t content_length_n;
++ /* for discarding request body */
++
+ ngx_http_headers_in_t headers_in;
+ ngx_http_headers_out_t headers_out;
+
+Only in nginx-1.0.10-patched/src/http: ngx_http_request.h~
+Only in nginx-1.0.10-patched/src/http: tags
@@ -0,0 +1,21 @@
+--- nginx-1.0.10/src/event/modules/ngx_epoll_module.c 2011-09-30 22:12:53.000000000 +0800
++++ nginx-1.0.10-patched/src/event/modules/ngx_epoll_module.c 2011-11-07 18:07:04.764111952 +0800
+@@ -681,6 +681,18 @@
+
+ wev = c->write;
+
++ if (c->fd == -1 || wev->instance != instance) {
++
++ /*
++ * the stale event from a file descriptor
++ * that was just closed in this iteration
++ */
++
++ ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
++ "epoll: stale event %p", c);
++ continue;
++ }
++
+ if ((revents & EPOLLOUT) && wev->active) {
+
+ if (flags & NGX_POST_THREAD_EVENTS) {
@@ -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,115 @@
+--- nginx-1.0.10/src/http/modules/ngx_http_log_module.c 2011-11-01 21:24:50.000000000 +0800
++++ nginx-1.0.10-patched/src/http/modules/ngx_http_log_module.c 2011-11-10 16:17:29.599039534 +0800
+@@ -61,6 +61,8 @@
+ time_t open_file_cache_valid;
+ ngx_uint_t open_file_cache_min_uses;
+
++ ngx_flag_t escape_non_ascii;
++
+ ngx_uint_t off; /* unsigned off:1 */
+ } ngx_http_log_loc_conf_t;
+
+@@ -104,7 +106,8 @@
+ uintptr_t data);
+ static u_char *ngx_http_log_variable(ngx_http_request_t *r, u_char *buf,
+ ngx_http_log_op_t *op);
+-static uintptr_t ngx_http_log_escape(u_char *dst, u_char *src, size_t size);
++static uintptr_t ngx_http_log_escape(ngx_http_log_loc_conf_t *lcf, u_char *dst,
++ u_char *src, size_t size);
+
+
+ static void *ngx_http_log_create_main_conf(ngx_conf_t *cf);
+@@ -146,6 +149,13 @@
+ 0,
+ NULL },
+
++ { ngx_string("log_escape_non_ascii"),
++ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
++ ngx_conf_set_flag_slot,
++ NGX_HTTP_LOC_CONF_OFFSET,
++ offsetof(ngx_http_log_loc_conf_t, escape_non_ascii),
++ NULL },
++
+ ngx_null_command
+ };
+
+@@ -637,6 +647,7 @@
+ ngx_http_log_variable_getlen(ngx_http_request_t *r, uintptr_t data)
+ {
+ uintptr_t len;
++ ngx_http_log_loc_conf_t *lcf;
+ ngx_http_variable_value_t *value;
+
+ value = ngx_http_get_indexed_variable(r, data);
+@@ -645,7 +656,9 @@
+ return 1;
+ }
+
+- len = ngx_http_log_escape(NULL, value->data, value->len);
++ lcf = ngx_http_get_module_loc_conf(r, ngx_http_log_module);
++
++ len = ngx_http_log_escape(lcf, NULL, value->data, value->len);
+
+ value->escape = len ? 1 : 0;
+
+@@ -656,6 +669,7 @@
+ static u_char *
+ ngx_http_log_variable(ngx_http_request_t *r, u_char *buf, ngx_http_log_op_t *op)
+ {
++ ngx_http_log_loc_conf_t *lcf;
+ ngx_http_variable_value_t *value;
+
+ value = ngx_http_get_indexed_variable(r, op->data);
+@@ -669,16 +683,18 @@
+ return ngx_cpymem(buf, value->data, value->len);
+
+ } else {
+- return (u_char *) ngx_http_log_escape(buf, value->data, value->len);
++ lcf = ngx_http_get_module_loc_conf(r, ngx_http_log_module);
++ return (u_char *) ngx_http_log_escape(lcf, buf, value->data, value->len);
+ }
+ }
+
+
+ static uintptr_t
+-ngx_http_log_escape(u_char *dst, u_char *src, size_t size)
++ngx_http_log_escape(ngx_http_log_loc_conf_t *lcf, u_char *dst, u_char *src,
++ size_t size)
+ {
+- ngx_uint_t n;
+- static u_char hex[] = "0123456789ABCDEF";
++ ngx_uint_t n;
++ static u_char hex[] = "0123456789ABCDEF";
+
+ static uint32_t escape[] = {
+ 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
+@@ -698,6 +714,12 @@
+ 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
+ };
+
++ if (lcf->escape_non_ascii) {
++ ngx_memset(&escape[4], 0xff, sizeof(uint32_t) * 4);
++
++ } else {
++ ngx_memzero(&escape[4], sizeof(uint32_t) * 4);
++ }
+
+ if (dst == NULL) {
+
+@@ -781,6 +803,7 @@
+ }
+
+ conf->open_file_cache = NGX_CONF_UNSET_PTR;
++ conf->escape_non_ascii = NGX_CONF_UNSET;
+
+ return conf;
+ }
+@@ -796,6 +819,8 @@
+ ngx_http_log_fmt_t *fmt;
+ ngx_http_log_main_conf_t *lmcf;
+
++ ngx_conf_merge_value(conf->escape_non_ascii, prev->escape_non_ascii, 1);
++
+ if (conf->open_file_cache == NGX_CONF_UNSET_PTR) {
+
+ conf->open_file_cache = prev->open_file_cache;
@@ -0,0 +1,12 @@
+--- nginx-1.0.10/src/http/ngx_http_core_module.c 2011-09-27 19:14:02.000000000 +0800
++++ nginx-1.0.10-patched/src/http/ngx_http_core_module.c 2011-10-13 15:02:24.414550532 +0800
+@@ -2542,6 +2542,9 @@
+ r->content_handler = NULL;
+ r->loc_conf = (*clcfp)->loc_conf;
+
++ /* clear the modules contexts */
++ ngx_memzero(r->ctx, sizeof(void *) * ngx_http_max_module);
++
+ ngx_http_update_location_config(r);
+
+ cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
@@ -0,0 +1,24 @@
+diff -ur nginx-1.0.10/auto/cc/gcc nginx-1.0.10-patched/auto/cc/gcc
+--- nginx-1.0.10/auto/cc/gcc 2011-06-27 19:53:00.205737804 +0800
++++ nginx-1.0.10-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.10/auto/cc/icc nginx-1.0.10-patched/auto/cc/icc
+--- nginx-1.0.10/auto/cc/icc 2011-06-27 19:52:56.370157068 +0800
++++ nginx-1.0.10-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"
Oops, something went wrong.

0 comments on commit 10d70ab

Please sign in to comment.