diff options
Diffstat (limited to 'src/http')
-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 | ||||
-rw-r--r-- | src/http/ngx_http_cache.c | 2 | ||||
-rw-r--r-- | src/http/ngx_http_cache.h | 20 | ||||
-rw-r--r-- | src/http/ngx_http_core_module.c | 2 | ||||
-rw-r--r-- | src/http/ngx_http_file_cache.c | 7 | ||||
-rw-r--r-- | src/http/ngx_http_parse.c | 2 | ||||
-rw-r--r-- | src/http/ngx_http_request.c | 4 | ||||
-rw-r--r-- | src/http/ngx_http_request.h | 4 |
13 files changed, 68 insertions, 41 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; } diff --git a/src/http/ngx_http_cache.c b/src/http/ngx_http_cache.c index 22572a58b..abdeae989 100644 --- a/src/http/ngx_http_cache.c +++ b/src/http/ngx_http_cache.c @@ -63,7 +63,7 @@ ngx_http_cache_t *ngx_http_cache_get(ngx_http_cache_hash_t *hash, c[i].refs++; - if ((!(c[i].notify && (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT))) + if ((!(c[i].notify && (ngx_event_flags & NGX_USE_KQUEUE_EVENT))) && (ngx_cached_time - c[i].updated >= hash->update)) { c[i].expired = 1; diff --git a/src/http/ngx_http_cache.h b/src/http/ngx_http_cache.h index 40f4852dd..aa6690265 100644 --- a/src/http/ngx_http_cache.h +++ b/src/http/ngx_http_cache.h @@ -14,11 +14,12 @@ /* - * The 7 uses before an allocation. + * The 3 bits allows the 7 uses before the cache entry allocation. * We can use maximum 7 bits, i.e up to the 127 uses. */ #define NGX_HTTP_CACHE_LAZY_ALLOCATION_BITS 3 + typedef struct { uint32_t crc; ngx_str_t key; @@ -45,7 +46,7 @@ typedef struct { off_t size; ngx_str_t value; } data; -} ngx_http_cache_t; +} ngx_http_cache_entry_t; typedef struct { @@ -62,7 +63,7 @@ typedef struct { #define NGX_HTTP_CACHE_NELTS 4 typedef struct { - ngx_http_cache_t *elts; + ngx_http_cache_entry_t *elts; size_t hash; size_t nelts; time_t life; @@ -76,9 +77,9 @@ typedef struct { typedef struct { ngx_http_cache_hash_t *hash; - ngx_http_cache_t *cache; + ngx_http_cache_entry_t *cache; ngx_file_t file; - ngx_str_t key; + ngx_array_t key; uint32_t crc; u_char md5[16]; ngx_path_t *path; @@ -90,7 +91,10 @@ typedef struct { ssize_t header_size; size_t file_start; ngx_log_t *log; -} ngx_http_cache_ctx_t; + + /* STUB */ + ngx_str_t key0; +} ngx_http_cache_t; @@ -99,6 +103,8 @@ typedef struct { #define NGX_HTTP_CACHE_THE_SAME 3 +#if 0 + ngx_http_cache_t *ngx_http_cache_get(ngx_http_cache_hash_t *cache, ngx_http_cleanup_t *cleanup, ngx_str_t *key, uint32_t *crc); @@ -127,5 +133,7 @@ int ngx_garbage_collector_http_cache_handler(ngx_gc_t *gc, ngx_str_t *name, char *ngx_http_set_cache_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); +#endif + #endif /* _NGX_HTTP_CACHE_H_INCLUDED_ */ diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c index c764b2a00..c4cb8b9f0 100644 --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -1828,7 +1828,7 @@ static char *ngx_http_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, "\"send_lowat\" is not supported, ignored"); diff --git a/src/http/ngx_http_file_cache.c b/src/http/ngx_http_file_cache.c index 8f920d240..1b258c943 100644 --- a/src/http/ngx_http_file_cache.c +++ b/src/http/ngx_http_file_cache.c @@ -9,19 +9,20 @@ #include <ngx_http.h> -#if (HAVE_OPENSSL_MD5_H) +#if (NGX_HAVE_OPENSSL_MD5_H) #include <openssl/md5.h> #else #include <md5.h> #endif -#if (HAVE_OPENSSL_MD5) +#if (NGX_OPENSSL_MD5) #define MD5Init MD5_Init #define MD5Update MD5_Update #define MD5Final MD5_Final #endif +#if 0 int ngx_http_cache_get_file(ngx_http_request_t *r, ngx_http_cache_ctx_t *ctx) { @@ -237,3 +238,5 @@ int ngx_garbage_collector_http_cache_handler(ngx_gc_t *gc, ngx_str_t *name, return NGX_OK; } + +#endif diff --git a/src/http/ngx_http_parse.c b/src/http/ngx_http_parse.c index bfe5efb17..a4e7d8045 100644 --- a/src/http/ngx_http_parse.c +++ b/src/http/ngx_http_parse.c @@ -686,7 +686,7 @@ ngx_int_t ngx_http_parse_complex_uri(ngx_http_request_t *r) ch = *p++; - while (p < r->uri_start + r->uri.len + 1 && r->args_start == NULL) { + while (p < r->uri_end && r->args_start == NULL) { /* * we use "ch = *p++" inside the cycle but this operation is safe diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c index a2cf1a025..b6013fcea 100644 --- a/src/http/ngx_http_request.c +++ b/src/http/ngx_http_request.c @@ -532,6 +532,7 @@ static void ngx_http_process_request_line(ngx_event_t *rev) r->uri.len = r->uri_end - r->uri_start; } + if (r->complex_uri || r->quoted_uri) { if (!(r->uri.data = ngx_palloc(r->pool, r->uri.len + 1))) { @@ -557,6 +558,7 @@ static void ngx_http_process_request_line(ngx_event_t *rev) r->uri.data = r->uri_start; } + r->unparsed_uri.len = r->uri_end - r->uri_start; r->unparsed_uri.data = r->uri_start; @@ -1751,7 +1753,7 @@ static void ngx_http_keepalive_handler(ngx_event_t *rev) ctx = (ngx_http_log_ctx_t *) rev->log->data; -#if (HAVE_KQUEUE) +#if (NGX_HAVE_KQUEUE) if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) { if (rev->pending_eof) { diff --git a/src/http/ngx_http_request.h b/src/http/ngx_http_request.h index 31b1187b0..141daa1b8 100644 --- a/src/http/ngx_http_request.h +++ b/src/http/ngx_http_request.h @@ -220,7 +220,7 @@ struct ngx_http_cleanup_s { struct { ngx_http_cache_hash_t *hash; - ngx_http_cache_t *cache; + ngx_http_cache_entry_t *cache; } cache; } data; @@ -254,7 +254,7 @@ struct ngx_http_request_s { void **srv_conf; void **loc_conf; - ngx_http_cache_t *cache; + ngx_http_cache_entry_t *cache; ngx_file_t file; |