diff options
Diffstat (limited to 'src/http/modules')
-rw-r--r-- | src/http/modules/ngx_http_gzip_filter.c | 32 | ||||
-rw-r--r-- | src/http/modules/ngx_http_index_handler.c | 18 | ||||
-rw-r--r-- | src/http/modules/proxy/ngx_http_proxy_cache.c | 2 | ||||
-rw-r--r-- | src/http/modules/proxy/ngx_http_proxy_handler.c | 8 | ||||
-rw-r--r-- | src/http/modules/proxy/ngx_http_proxy_handler.h | 2 | ||||
-rw-r--r-- | src/http/modules/proxy/ngx_http_proxy_upstream.c | 6 |
6 files changed, 41 insertions, 27 deletions
diff --git a/src/http/modules/ngx_http_gzip_filter.c b/src/http/modules/ngx_http_gzip_filter.c index f8980af52..b093d582f 100644 --- a/src/http/modules/ngx_http_gzip_filter.c +++ b/src/http/modules/ngx_http_gzip_filter.c @@ -237,14 +237,14 @@ static ngx_http_log_op_name_t ngx_http_gzip_log_fmt_ops[] = { static u_char gzheader[10] = { 0x1f, 0x8b, Z_DEFLATED, 0, 0, 0, 0, 0, 0, 3 }; -#if (HAVE_LITTLE_ENDIAN) +#if (NGX_HAVE_LITTLE_ENDIAN) struct gztrailer { uint32_t crc32; uint32_t zlen; }; -#else /* HAVE_BIG_ENDIAN */ +#else /* NGX_HAVE_BIG_ENDIAN */ struct gztrailer { u_char crc32[4]; @@ -437,7 +437,8 @@ static ngx_int_t ngx_http_gzip_proxied(ngx_http_request_t *r, static ngx_int_t ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in) { - int rc, wbits, memlevel, last; + int rc, wbits, memlevel; + ngx_int_t last; struct gztrailer *trailer; ngx_buf_t *b; ngx_chain_t *cl; @@ -469,7 +470,7 @@ static ngx_int_t ngx_http_gzip_body_filter(ngx_http_request_t *r, /* * We preallocate a memory for zlib in one buffer (200K-400K), this * dicreases a number of malloc() and free() calls and also probably - * dicreases a number of syscalls (sbrk() or so). + * dicreases a number of syscalls (sbrk() and so on). * Besides we free this memory as soon as the gzipping will complete * and do not wait while a whole response will be sent to a client. * @@ -512,8 +513,19 @@ static ngx_int_t ngx_http_gzip_body_filter(ngx_http_request_t *r, } cl->buf = b; cl->next = NULL; - ctx->out = cl; - ctx->last_out = &cl->next; + + /* + * We pass the gzheader to the next filter now to avoid its linking + * to the ctx->busy chain. zlib does not usually output the compressed + * data in the initial iterations, so the gzheader that was linked + * to the ctx->busy chain would be flushed by ngx_http_write_filter(). + */ + + if (ngx_http_next_body_filter(r, cl) == NGX_ERROR) { + return ngx_http_gzip_error(ctx); + } + + ctx->last_out = &ctx->out; ctx->crc32 = crc32(0L, Z_NULL, 0); ctx->flush = Z_NO_FLUSH; @@ -727,7 +739,7 @@ static ngx_int_t ngx_http_gzip_body_filter(ngx_http_request_t *r, b->last += 8; } -#if (HAVE_LITTLE_ENDIAN) +#if (NGX_HAVE_LITTLE_ENDIAN) trailer->crc32 = ctx->crc32; trailer->zlen = ctx->zin; #else @@ -763,7 +775,7 @@ static ngx_int_t ngx_http_gzip_body_filter(ngx_http_request_t *r, } } - if (last == NGX_AGAIN) { + if (last == NGX_AGAIN && !ctx->done) { return NGX_AGAIN; } @@ -881,7 +893,9 @@ static int ngx_http_gzip_error(ngx_http_gzip_ctx_t *ctx) { deflateEnd(&ctx->zstream); - ngx_pfree(ctx->request->pool, ctx->preallocated); + if (ctx->preallocated) { + ngx_pfree(ctx->request->pool, ctx->preallocated); + } ctx->zstream.avail_in = 0; ctx->zstream.avail_out = 0; diff --git a/src/http/modules/ngx_http_index_handler.c b/src/http/modules/ngx_http_index_handler.c index 013f62b46..3386953bd 100644 --- a/src/http/modules/ngx_http_index_handler.c +++ b/src/http/modules/ngx_http_index_handler.c @@ -10,19 +10,19 @@ typedef struct { - ngx_array_t indices; - size_t max_index_len; - ngx_http_cache_hash_t *index_cache; + ngx_array_t indices; + size_t max_index_len; + ngx_http_cache_hash_t *index_cache; } ngx_http_index_loc_conf_t; typedef struct { - ngx_uint_t index; - u_char *last; - ngx_str_t path; - ngx_str_t redirect; - ngx_http_cache_t *cache; - unsigned tested:1; + ngx_uint_t index; + u_char *last; + ngx_str_t path; + ngx_str_t redirect; + ngx_http_cache_entry_t *cache; + ngx_uint_t tested; /* unsigned tested:1 */ } ngx_http_index_ctx_t; diff --git a/src/http/modules/proxy/ngx_http_proxy_cache.c b/src/http/modules/proxy/ngx_http_proxy_cache.c index f0b56f548..86b8424c6 100644 --- a/src/http/modules/proxy/ngx_http_proxy_cache.c +++ b/src/http/modules/proxy/ngx_http_proxy_cache.c @@ -297,7 +297,7 @@ void ngx_http_proxy_cache_busy_lock(ngx_http_proxy_ctx_t *p) if (rc == NGX_AGAIN) { - if ((ngx_event_flags & (NGX_USE_CLEAR_EVENT|NGX_HAVE_KQUEUE_EVENT)) + if ((ngx_event_flags & (NGX_USE_CLEAR_EVENT|NGX_USE_KQUEUE_EVENT)) && !p->request->connection->write->active) { /* diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.c b/src/http/modules/proxy/ngx_http_proxy_handler.c index c0a8cf3d9..425a1a6af 100644 --- a/src/http/modules/proxy/ngx_http_proxy_handler.c +++ b/src/http/modules/proxy/ngx_http_proxy_handler.c @@ -414,7 +414,7 @@ void ngx_http_proxy_check_broken_connection(ngx_event_t *ev) ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ev->log, 0, "http proxy check client, write event:%d", ev->write); -#if (HAVE_KQUEUE) +#if (NGX_HAVE_KQUEUE) if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) { @@ -563,9 +563,9 @@ void ngx_http_proxy_busy_lock_handler(ngx_event_t *rev) */ #if 0 -#if (HAVE_KQUEUE) +#if (NGX_HAVE_KQUEUE) - if ((ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) && rev->kq_eof) { + if ((ngx_event_flags & NGX_USE_KQUEUE_EVENT) && rev->kq_eof) { ngx_http_busy_unlock(p->lcf->busy_lock, &p->busy_lock); ngx_del_timer(rev); @@ -1400,7 +1400,7 @@ static char *ngx_http_proxy_lowat_check(ngx_conf_t *cf, void *post, void *data) return NGX_CONF_ERROR; } -#elif !(HAVE_SO_SNDLOWAT) +#elif !(NGX_HAVE_SO_SNDLOWAT) ngx_conf_log_error(NGX_LOG_WARN, cf, 0, "\"proxy_send_lowat\" is not supported, ignored"); diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.h b/src/http/modules/proxy/ngx_http_proxy_handler.h index 094ee3bd1..8ab88ad54 100644 --- a/src/http/modules/proxy/ngx_http_proxy_handler.h +++ b/src/http/modules/proxy/ngx_http_proxy_handler.h @@ -142,7 +142,7 @@ typedef struct { typedef struct { - ngx_http_cache_ctx_t ctx; + ngx_http_cache_t ctx; ngx_uint_t status; ngx_str_t status_line; diff --git a/src/http/modules/proxy/ngx_http_proxy_upstream.c b/src/http/modules/proxy/ngx_http_proxy_upstream.c index 0852a426f..23d40c493 100644 --- a/src/http/modules/proxy/ngx_http_proxy_upstream.c +++ b/src/http/modules/proxy/ngx_http_proxy_upstream.c @@ -782,7 +782,7 @@ static void ngx_http_proxy_send_request(ngx_http_proxy_ctx_t *p) ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http proxy send request"); -#if (HAVE_KQUEUE) +#if (NGX_HAVE_KQUEUE) if ((ngx_event_flags & NGX_USE_KQUEUE_EVENT) && !p->request_sent @@ -1287,8 +1287,8 @@ static void ngx_http_proxy_send_response(ngx_http_proxy_ctx_t *p) header->length = r->headers_out.content_length_n; p->cache->ctx.length = r->headers_out.content_length_n; - header->key_len = p->cache->ctx.key.len; - ngx_memcpy(&header->key, p->cache->ctx.key.data, header->key_len); + header->key_len = p->cache->ctx.key0.len; + ngx_memcpy(&header->key, p->cache->ctx.key0.data, header->key_len); header->key[header->key_len] = LF; } |