diff options
Diffstat (limited to '')
| -rw-r--r-- | src/http/modules/ngx_http_gzip_filter.c | 27 | ||||
| -rw-r--r-- | src/http/modules/ngx_http_index_handler.c | 3 | ||||
| -rw-r--r-- | src/http/modules/ngx_http_not_modified_filter.c | 4 | ||||
| -rw-r--r-- | src/http/modules/ngx_http_static_handler.c | 3 | ||||
| -rw-r--r-- | src/http/modules/proxy/ngx_http_proxy_cache.c | 26 | ||||
| -rw-r--r-- | src/http/modules/proxy/ngx_http_proxy_handler.c | 30 | ||||
| -rw-r--r-- | src/http/modules/proxy/ngx_http_proxy_upstream.c | 72 | ||||
| -rw-r--r-- | src/http/ngx_http.c | 15 | ||||
| -rw-r--r-- | src/http/ngx_http_busy_lock.c | 5 | ||||
| -rw-r--r-- | src/http/ngx_http_core_module.c | 21 | ||||
| -rw-r--r-- | src/http/ngx_http_core_module.h | 1 | ||||
| -rw-r--r-- | src/http/ngx_http_file_cache.c | 13 | ||||
| -rw-r--r-- | src/http/ngx_http_header_filter.c | 6 | ||||
| -rw-r--r-- | src/http/ngx_http_headers.c | 7 | ||||
| -rw-r--r-- | src/http/ngx_http_parse.c | 4 | ||||
| -rw-r--r-- | src/http/ngx_http_request.c | 8 | ||||
| -rw-r--r-- | src/http/ngx_http_write_filter.c | 34 |
17 files changed, 149 insertions, 130 deletions
diff --git a/src/http/modules/ngx_http_gzip_filter.c b/src/http/modules/ngx_http_gzip_filter.c index fae9c9edb..34d872ca5 100644 --- a/src/http/modules/ngx_http_gzip_filter.c +++ b/src/http/modules/ngx_http_gzip_filter.c @@ -377,9 +377,11 @@ static int ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in) ctx->zstream.avail_out = conf->bufs.size; } -ngx_log_debug(r->connection->log, "deflate(): %08x %08x %d %d %d" _ - ctx->zstream.next_in _ ctx->zstream.next_out _ - ctx->zstream.avail_in _ ctx->zstream.avail_out _ ctx->flush); + ngx_log_debug5(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "deflate in: ni:%X no:%X ai:%d ao:%d fl:%d", + ctx->zstream.next_in, ctx->zstream.next_out, + ctx->zstream.avail_in, ctx->zstream.avail_out, + ctx->flush); rc = deflate(&ctx->zstream, ctx->flush); if (rc != Z_OK && rc != Z_STREAM_END) { @@ -388,9 +390,11 @@ ngx_log_debug(r->connection->log, "deflate(): %08x %08x %d %d %d" _ return ngx_http_gzip_error(ctx); } -ngx_log_debug(r->connection->log, "DEFLATE(): %08x %08x %d %d %d" _ - ctx->zstream.next_in _ ctx->zstream.next_out _ - ctx->zstream.avail_in _ ctx->zstream.avail_out _ rc); + ngx_log_debug5(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "deflate out: ni:%X no:%X ai:%d ao:%d rc:%d", + ctx->zstream.next_in, ctx->zstream.next_out, + ctx->zstream.avail_in, ctx->zstream.avail_out, + rc); ctx->in_hunk->pos = (char *) ctx->zstream.next_in; ctx->out_hunk->last = (char *) ctx->zstream.next_out; @@ -512,7 +516,6 @@ static void *ngx_http_gzip_filter_alloc(void *opaque, u_int items, u_int size) int alloc; void *p; - alloc = items * size; if (alloc % 512 != 0) { @@ -527,10 +530,9 @@ static void *ngx_http_gzip_filter_alloc(void *opaque, u_int items, u_int size) ctx->free_mem += alloc; ctx->allocated -= alloc; -#if 1 - ngx_log_debug(ctx->request->connection->log, "ALLOC: %d:%d:%d:%08X" _ - items _ size _ alloc _ p); -#endif + ngx_log_debug4(NGX_LOG_DEBUG_HTTP, ctx->request->connection->log, 0, + "gzip alloc: n:%d s:%d a:%d p:%08X", + items, size, alloc, p); return p; } @@ -550,7 +552,8 @@ static void ngx_http_gzip_filter_free(void *opaque, void *address) ngx_http_gzip_ctx_t *ctx = opaque; #if 0 - ngx_log_debug(ctx->request->connection->log, "FREE: %08X" _ address); + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ctx->request->connection->log, 0, + "gzip free: %X", address); #endif } diff --git a/src/http/modules/ngx_http_index_handler.c b/src/http/modules/ngx_http_index_handler.c index edcf54a2d..029843e70 100644 --- a/src/http/modules/ngx_http_index_handler.c +++ b/src/http/modules/ngx_http_index_handler.c @@ -286,7 +286,8 @@ static ngx_int_t ngx_http_index_test_dir(ngx_http_request_t *r, ctx->path.data[ctx->path.len - 1] = '\0'; ctx->path.data[ctx->path.len] = '\0'; -ngx_log_debug(r->connection->log, "IS_DIR: %s" _ ctx->path.data); + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "http check dir: \"%s\"", ctx->path.data); if (ngx_file_info(ctx->path.data, &r->file.info) == -1) { diff --git a/src/http/modules/ngx_http_not_modified_filter.c b/src/http/modules/ngx_http_not_modified_filter.c index 11cc21cb9..e1a961f1f 100644 --- a/src/http/modules/ngx_http_not_modified_filter.c +++ b/src/http/modules/ngx_http_not_modified_filter.c @@ -49,8 +49,8 @@ static int ngx_http_not_modified_header_filter(ngx_http_request_t *r) ims = ngx_http_parse_time(r->headers_in.if_modified_since->value.data, r->headers_in.if_modified_since->value.len); - ngx_log_debug(r->connection->log, "%d %d" _ - ims _ r->headers_out.last_modified_time); + ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "http ims:%d lm:%d", ims, r->headers_out.last_modified_time); /* * I think that the equality of the dates is correcter diff --git a/src/http/modules/ngx_http_static_handler.c b/src/http/modules/ngx_http_static_handler.c index 617bb4d80..699747123 100644 --- a/src/http/modules/ngx_http_static_handler.c +++ b/src/http/modules/ngx_http_static_handler.c @@ -59,7 +59,8 @@ static ngx_int_t ngx_http_static_handler(ngx_http_request_t *r) char *last; uint32_t file_crc, redirect_crc; ngx_fd_t fd; - ngx_int_t rc, level; + ngx_int_t rc; + ngx_uint_t level; ngx_str_t name, location; ngx_err_t err; ngx_log_t *log; diff --git a/src/http/modules/proxy/ngx_http_proxy_cache.c b/src/http/modules/proxy/ngx_http_proxy_cache.c index 9661cff96..ce2226d41 100644 --- a/src/http/modules/proxy/ngx_http_proxy_cache.c +++ b/src/http/modules/proxy/ngx_http_proxy_cache.c @@ -167,8 +167,9 @@ static int ngx_http_proxy_process_cached_header(ngx_http_proxy_ctx_t *p) ngx_cpystrn(c->status_line.data, p->status_start, c->status_line.len + 1); - ngx_log_debug(r->connection->log, "http cache status %d '%s'" _ - c->status _ c->status_line.data); + ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "http cache status %d \"%s\"", + c->status, c->status_line.data); /* TODO: ngx_init_table */ c->headers_in.headers = ngx_create_table(r->pool, 20); @@ -212,8 +213,9 @@ static int ngx_http_proxy_process_cached_header(ngx_http_proxy_ctx_t *p) } } - ngx_log_debug(r->connection->log, "HTTP cache header: '%s: %s'" _ - h->key.data _ h->value.data); + ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "http cache header: \"%s: %s\"", + h->key.data, h->value.data); continue; @@ -221,7 +223,8 @@ static int ngx_http_proxy_process_cached_header(ngx_http_proxy_ctx_t *p) /* a whole header has been parsed successfully */ - ngx_log_debug(r->connection->log, "HTTP header done"); + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "http cache header done"); c->ctx.file_start = p->header_in->pos - p->header_in->start; @@ -253,7 +256,8 @@ void ngx_http_proxy_cache_busy_lock(ngx_http_proxy_ctx_t *p) rc = ngx_http_busy_lock_cachable(p->lcf->busy_lock, &p->busy_lock, p->try_busy_lock); -ngx_log_debug(p->request->connection->log, "LOCK CACHABLE: %d" _ rc); + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, p->request->connection->log, 0, + "http cache busy lock cachable: %d", rc); if (rc == NGX_OK) { if (p->try_busy_lock) { @@ -354,8 +358,9 @@ static void ngx_http_proxy_cache_look_complete_request(ngx_http_proxy_ctx_t *p) return; } -ngx_log_debug(p->request->connection->log, "OLD: %d, NEW: %d" _ - p->cache->ctx.file.fd _ ctx->file.fd); + ngx_log_debug2(NGX_LOG_DEBUG_HTTP, p->request->connection->log, 0, + "http cache old fd:%d, new fd:%d", + p->cache->ctx.file.fd, ctx->file.fd); if (p->cache->ctx.file.fd != NGX_INVALID_FILE) { if (ngx_close_file(p->cache->ctx.file.fd) == NGX_FILE_ERROR) { @@ -603,8 +608,9 @@ int ngx_http_proxy_update_cache(ngx_http_proxy_ctx_t *p) ep = p->upstream->event_pipe; -ngx_log_debug(p->request->connection->log, "LEN: " OFF_T_FMT ", " OFF_T_FMT _ - p->cache->ctx.length _ ep->read_length); + ngx_log_debug2(NGX_LOG_DEBUG_HTTP, p->request->connection->log, 0, + "http cache update len: " OFF_T_FMT ":" OFF_T_FMT, + p->cache->ctx.length, ep->read_length); if (p->cache->ctx.length == -1) { /* TODO: test rc */ diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.c b/src/http/modules/proxy/ngx_http_proxy_handler.c index 84396a948..59b1c06e8 100644 --- a/src/http/modules/proxy/ngx_http_proxy_handler.c +++ b/src/http/modules/proxy/ngx_http_proxy_handler.c @@ -346,7 +346,7 @@ void ngx_http_proxy_check_broken_connection(ngx_event_t *wev) ngx_http_request_t *r; ngx_http_proxy_ctx_t *p; - ngx_log_debug(wev->log, "http proxy check client"); + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, wev->log, 0, "http proxy check client"); c = wev->data; r = c->data; @@ -362,14 +362,16 @@ void ngx_http_proxy_check_broken_connection(ngx_event_t *wev) if (!p->cachable && p->upstream->peer.connection) { ngx_log_error(NGX_LOG_INFO, wev->log, wev->kq_errno, - "client closed prematurely connection, " + "kevent() reported that client have closed " + "prematurely connection, " "so upstream connection is closed too"); ngx_http_proxy_finalize_request(p, NGX_HTTP_CLIENT_CLOSED_REQUEST); return; } ngx_log_error(NGX_LOG_INFO, wev->log, wev->kq_errno, - "client closed prematurely connection"); + "kevent() reported that client have closed " + "prematurely connection"); if (p->upstream == NULL || p->upstream->peer.connection == NULL) { ngx_http_proxy_finalize_request(p, NGX_HTTP_CLIENT_CLOSED_REQUEST); @@ -385,7 +387,7 @@ void ngx_http_proxy_busy_lock_handler(ngx_event_t *rev) ngx_http_request_t *r; ngx_http_proxy_ctx_t *p; - ngx_log_debug(rev->log, "busy lock"); + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, rev->log, 0, "http proxy busy lock"); c = rev->data; r = c->data; @@ -412,11 +414,12 @@ void ngx_http_proxy_busy_lock_handler(ngx_event_t *rev) return; } - ngx_log_debug(rev->log, "client sent while busy lock"); + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, rev->log, 0, + "http proxy: client sent while busy lock"); /* * TODO: kevent() notify about error, otherwise we need to - * call ngx_peek(): recv(MSG_PEEK) to get errno. THINK about aio + * call ngx_peek(): recv(MSG_PEEK) to get errno. THINK about aio. * if there's no error we need to disable event. */ @@ -452,7 +455,8 @@ void ngx_http_proxy_finalize_request(ngx_http_proxy_ctx_t *p, int rc) r = p->request; - ngx_log_debug(r->connection->log, "finalize http proxy request"); + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "finalize http proxy request"); if (p->upstream && p->upstream->peer.connection) { ngx_http_proxy_close_connection(p); @@ -470,12 +474,15 @@ void ngx_http_proxy_finalize_request(ngx_http_proxy_ctx_t *p, int rc) } if (p->upstream && p->upstream->event_pipe) { -ngx_log_debug(r->connection->log, "TEMP FD: %d" _ - p->upstream->event_pipe->temp_file->file.fd); + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "http proxy temp fd: %d", + p->upstream->event_pipe->temp_file->file.fd); } if (p->cache) { -ngx_log_debug(r->connection->log, "CACHE FD: %d" _ p->cache->ctx.file.fd); + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "http proxy cache fd: %d", + p->cache->ctx.file.fd); } if (p->upstream && p->upstream->event_pipe) { @@ -504,7 +511,8 @@ void ngx_http_proxy_close_connection(ngx_http_proxy_ctx_t *p) p->lcf->busy_lock->busy--; } - ngx_log_debug(c->log, "proxy close connection: %d" _ c->fd); + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, + "http proxy close connection: %d", c->fd); if (c->fd == -1) { #if 0 diff --git a/src/http/modules/proxy/ngx_http_proxy_upstream.c b/src/http/modules/proxy/ngx_http_proxy_upstream.c index d36cbee10..a65b86470 100644 --- a/src/http/modules/proxy/ngx_http_proxy_upstream.c +++ b/src/http/modules/proxy/ngx_http_proxy_upstream.c @@ -192,15 +192,19 @@ static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_proxy_ctx_t *p) *(h->last++) = CR; *(h->last++) = LF; - ngx_log_debug(r->connection->log, "proxy: '%s: %s'" _ - header[i].key.data _ header[i].value.data); + ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "http proxy header: \"%s: %s\"", + header[i].key.data, header[i].value.data); } /* add "\r\n" at the header end */ *(h->last++) = CR; *(h->last++) = LF; - /* STUB */ *(h->last) = '\0'; - ngx_log_debug(r->connection->log, "PROXY:\n'%s'" _ h->pos); +#if (NGX_DEBUG) + *(h->last) = '\0'; + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "http proxy header:\n\"%s\"", h->pos); +#endif return chain; } @@ -218,8 +222,9 @@ static void ngx_http_proxy_init_upstream(void *data) r = p->request; -ngx_log_debug(r->connection->log, "timer_set: %d" _ - r->connection->read->timer_set); + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "http proxy set timer: %d", + r->connection->read->timer_set); if (r->connection->read->timer_set) { ngx_del_timer(r->connection->read); @@ -588,7 +593,7 @@ static void ngx_http_proxy_send_request_handler(ngx_event_t *wev) static void ngx_http_proxy_dummy_handler(ngx_event_t *wev) { - ngx_log_debug(wev->log, "dummy handler"); + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, wev->log, 0, "http proxy dummy handler"); } @@ -603,7 +608,8 @@ static void ngx_http_proxy_process_upstream_status_line(ngx_event_t *rev) p = c->data; p->action = "reading upstream status line"; - ngx_log_debug(rev->log, "http proxy process status line"); + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, rev->log, 0, + "http proxy process status line"); if (rev->timedout) { ngx_http_proxy_next_upstream(p, NGX_HTTP_PROXY_FT_TIMEOUT); @@ -717,8 +723,9 @@ static void ngx_http_proxy_process_upstream_status_line(ngx_event_t *rev) ngx_cpystrn(p->upstream->status_line.data, p->status_start, p->upstream->status_line.len + 1); - ngx_log_debug(rev->log, "http proxy status %d '%s'" _ - p->upstream->status _ p->upstream->status_line.data); + ngx_log_debug2(NGX_LOG_DEBUG_HTTP, rev->log, 0, + "http proxy status %d \"%s\"", + p->upstream->status, p->upstream->status_line.data); if (p->upstream->headers_in.headers) { p->upstream->headers_in.headers->nelts = 0; @@ -747,7 +754,8 @@ static void ngx_http_proxy_process_upstream_headers(ngx_event_t *rev) r = p->request; p->action = "reading upstream headers"; - ngx_log_debug(rev->log, "http proxy process header line"); + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, rev->log, 0, + "http proxy process header line"); if (rev->timedout) { ngx_http_proxy_next_upstream(p, NGX_HTTP_PROXY_FT_TIMEOUT); @@ -818,8 +826,9 @@ static void ngx_http_proxy_process_upstream_headers(ngx_event_t *rev) } } - ngx_log_debug(c->log, "HTTP proxy header: '%s: %s'" _ - h->key.data _ h->value.data); + ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, + "http proxy header: \"%s: %s\"", + h->key.data, h->value.data); continue; @@ -827,7 +836,8 @@ static void ngx_http_proxy_process_upstream_headers(ngx_event_t *rev) /* a whole header has been parsed successfully */ - ngx_log_debug(c->log, "HTTP header done"); + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, + "http proxy header done"); /* TODO: hook to process the upstream header */ @@ -1072,13 +1082,15 @@ static void ngx_http_proxy_process_body(ngx_event_t *ev) c = ev->data; if (ev->write) { - ngx_log_debug(ev->log, "http proxy process downstream"); + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, ev->log, 0, + "http proxy process downstream"); r = c->data; p = ngx_http_get_module_ctx(r, ngx_http_proxy_module); p->action = "sending to client"; } else { - ngx_log_debug(ev->log, "http proxy process upstream"); + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, ev->log, 0, + "http proxy process upstream"); p = c->data; r = p->request; p->action = "reading upstream body"; @@ -1125,7 +1137,8 @@ static void ngx_http_proxy_process_body(ngx_event_t *ev) } if (ep->upstream_done || ep->upstream_eof || ep->upstream_error) { - ngx_log_debug(ev->log, "http proxy upstream exit"); + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, ev->log, 0, + "http proxy upstream exit"); ngx_http_busy_unlock(p->lcf->busy_lock, &p->busy_lock); ngx_http_proxy_finalize_request(p, 0); return; @@ -1133,30 +1146,12 @@ static void ngx_http_proxy_process_body(ngx_event_t *ev) } if (ep->downstream_error) { - ngx_log_debug(ev->log, "http proxy downstream error"); + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, ev->log, 0, + "http proxy downstream error"); if (!p->cachable && p->upstream->peer.connection) { ngx_http_proxy_finalize_request(p, 0); } } - -#if 0 - if (ep->downstream_done) { - ngx_log_debug(ev->log, "http proxy downstream done"); - ngx_http_proxy_finalize_request(p, 0); - return; - } - - if (ep->downstream_error) { - ngx_log_debug(ev->log, "http proxy downstream error"); - if (!p->cachable && p->upstream->peer.connection) { - ngx_http_proxy_close_connection(p); - } - - if (p->upstream->peer.connection == NULL) { - ngx_http_close_request(r); - } - } -#endif } @@ -1164,7 +1159,8 @@ static void ngx_http_proxy_next_upstream(ngx_http_proxy_ctx_t *p, int ft_type) { int status; -ngx_log_debug(p->request->connection->log, "next upstream: %d" _ ft_type); + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, p->request->connection->log, 0, + "http proxy next upstream: %d", ft_type); ngx_http_busy_unlock(p->lcf->busy_lock, &p->busy_lock); diff --git a/src/http/ngx_http.c b/src/http/ngx_http.c index 08958141a..234992d58 100644 --- a/src/http/ngx_http.c +++ b/src/http/ngx_http.c @@ -589,23 +589,26 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) } } - /* DEBUG STUFF */ +#if (NGX_DEBUG) in_port = in_ports.elts; for (p = 0; p < in_ports.nelts; p++) { -ngx_log_debug(cf->log, "port: %d %08x" _ in_port[p].port _ &in_port[p]); + ngx_log_debug2(NGX_LOG_DEBUG_HTTP, cf->log, 0, + "port: %d %08x", in_port[p].port, &in_port[p]); in_addr = in_port[p].addrs.elts; for (a = 0; a < in_port[p].addrs.nelts; a++) { char ip[20]; ngx_inet_ntop(AF_INET, (char *) &in_addr[a].addr, ip, 20); -ngx_log_debug(cf->log, "%s %08x" _ ip _ in_addr[a].core_srv_conf); + ngx_log_debug2(NGX_LOG_DEBUG_HTTP, cf->log, 0, + "%s %08x", ip, in_addr[a].core_srv_conf); s_name = in_addr[a].names.elts; for (n = 0; n < in_addr[a].names.nelts; n++) { -ngx_log_debug(cf->log, "%s %08x" _ s_name[n].name.data _ - s_name[n].core_srv_conf); + ngx_log_debug2(NGX_LOG_DEBUG_HTTP, cf->log, 0, + "%s %08x", s_name[n].name.data, + s_name[n].core_srv_conf); } } } - /**/ +#endif return NGX_CONF_OK; } diff --git a/src/http/ngx_http_busy_lock.c b/src/http/ngx_http_busy_lock.c index b4fdefe64..30cec2354 100644 --- a/src/http/ngx_http_busy_lock.c +++ b/src/http/ngx_http_busy_lock.c @@ -59,8 +59,9 @@ int ngx_http_busy_lock_cachable(ngx_http_busy_lock_t *bl, rc = ngx_http_busy_lock_look_cachable(bl, bc, lock); -ngx_log_debug(bc->event->log, "BUSYLOCK: %d %d:%d" _ - rc _ bl->waiting _ bl->max_waiting); + ngx_log_debug3(NGX_LOG_DEBUG_HTTP, bc->event->log, 0, + "http busylock: %d w:%d mw::%d", + rc, bl->waiting, bl->max_waiting); if (rc == NGX_OK) { /* no the same request, there's free slot */ return NGX_OK; diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c index ad5b3aa0f..20c7a5594 100644 --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -305,7 +305,7 @@ static void ngx_http_phase_event_handler(ngx_event_t *ev) c = ev->data; r = c->data; - ngx_log_debug(ev->log, "phase event handler"); + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, ev->log, 0, "phase event handler"); ngx_http_run_phases(r); @@ -612,19 +612,6 @@ int ngx_http_redirect(ngx_http_request_t *r, int redirect) } -int ngx_http_error(ngx_http_request_t *r, int error) -{ - /* STUB */ - ngx_log_debug(r->connection->log, "http error: %d" _ error); - - /* log request */ - - ngx_http_special_response_handler(r, error); - ngx_http_close_request(r, 0); - return NGX_OK; -} - - ngx_int_t ngx_http_set_exten(ngx_http_request_t *r) { ngx_int_t i; @@ -706,13 +693,15 @@ int ngx_http_delay_handler(ngx_http_request_t *r) static int on; if (on++ == 0) { - ngx_log_debug(r->connection->log, "SET http delay"); + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "http set delay"); ngx_add_timer(r->connection->write, 10000); return NGX_AGAIN; } r->connection->write->timedout = 0; - ngx_log_debug(r->connection->log, "RESET http delay"); + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "http reset delay"); return NGX_DECLINED; } diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h index 78de144d1..a6738e699 100644 --- a/src/http/ngx_http_core_module.h +++ b/src/http/ngx_http_core_module.h @@ -161,7 +161,6 @@ ngx_int_t ngx_http_set_exten(ngx_http_request_t *r); int ngx_http_internal_redirect(ngx_http_request_t *r, ngx_str_t *uri, ngx_str_t *args); -int ngx_http_error(ngx_http_request_t *r, int error); #endif /* _NGX_HTTP_CORE_H_INCLUDED_ */ diff --git a/src/http/ngx_http_file_cache.c b/src/http/ngx_http_file_cache.c index b8a24dba7..038056fb9 100644 --- a/src/http/ngx_http_file_cache.c +++ b/src/http/ngx_http_file_cache.c @@ -36,12 +36,14 @@ int ngx_http_cache_get_file(ngx_http_request_t *r, ngx_http_cache_ctx_t *ctx) ngx_md5_text(ctx->file.name.data + ctx->path->name.len + 1 + ctx->path->len, ctx->md5); -ngx_log_debug(r->connection->log, "URL: %s, md5: %s" _ ctx->key.data _ - ctx->file.name.data + ctx->path->name.len + 1 + ctx->path->len); + ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "file cache uri: %s, md5: %s", ctx->key.data, + ctx->file.name.data + ctx->path->name.len + 1 + ctx->path->len); ngx_create_hashed_filename(&ctx->file, ctx->path); -ngx_log_debug(r->connection->log, "FILE: %s" _ ctx->file.name.data); + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "file cache name: %s", ctx->file.name.data); /* TODO: look open files cache */ @@ -129,7 +131,10 @@ int ngx_http_cache_open_file(ngx_http_cache_ctx_t *ctx, ngx_file_uniq_t uniq) ctx->buf->last += n; if (ctx->expires < ngx_time()) { -ngx_log_debug(ctx->log, "EXPIRED"); + + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, ctx->log, 0, + "http file cache expired"); + return NGX_HTTP_CACHE_STALE; } diff --git a/src/http/ngx_http_header_filter.c b/src/http/ngx_http_header_filter.c index 8f8ffca4e..801ab993e 100644 --- a/src/http/ngx_http_header_filter.c +++ b/src/http/ngx_http_header_filter.c @@ -333,10 +333,10 @@ static int ngx_http_header_filter(ngx_http_request_t *r) *(h->last++) = CR; *(h->last++) = LF; } - /* STUB */ +#if (NGX_DEBUG) *(h->last) = '\0'; - ngx_log_debug(r->connection->log, "%s\n" _ h->pos); - /**/ + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "%s\n", h->pos); +#endif /* the end of HTTP header */ *(h->last++) = CR; *(h->last++) = LF; diff --git a/src/http/ngx_http_headers.c b/src/http/ngx_http_headers.c index 150ad1eeb..128744917 100644 --- a/src/http/ngx_http_headers.c +++ b/src/http/ngx_http_headers.c @@ -11,16 +11,17 @@ ngx_http_header_t ngx_http_headers_in[] = { offsetof(ngx_http_headers_in_t, if_modified_since) }, { ngx_string("User-Agent"), offsetof(ngx_http_headers_in_t, user_agent) }, { ngx_string("Referer"), offsetof(ngx_http_headers_in_t, referer) }, - { ngx_string("Content-Length"), offsetof(ngx_http_headers_in_t, content_length) }, - { ngx_string("Accept-Encoding"), - offsetof(ngx_http_headers_in_t, accept_encoding) }, + { ngx_string("Range"), offsetof(ngx_http_headers_in_t, range) }, #if 0 { ngx_string("If-Range"), offsetof(ngx_http_headers_in_t, if_range) }, #endif + { ngx_string("Accept-Encoding"), + offsetof(ngx_http_headers_in_t, accept_encoding) }, + { ngx_string("Authorization"), offsetof(ngx_http_headers_in_t, authorization) }, diff --git a/src/http/ngx_http_parse.c b/src/http/ngx_http_parse.c index 38ee9ecb9..ad9dac085 100644 --- a/src/http/ngx_http_parse.c +++ b/src/http/ngx_http_parse.c @@ -648,8 +648,8 @@ ngx_int_t ngx_http_parse_complex_uri(ngx_http_request_t *r) while (p < r->uri_start + r->uri.len + 1) { -ngx_log_debug(r->connection->log, "S: %d UN: '%x:%c', URI: '%c'" _ - state _ ch _ ch _ *u); + ngx_log_debug4(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "s:%d in:'%x:%c', out:'%c'", state, ch, ch, *u); switch (state) { case sw_usual: diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c index ff53a7ba6..90605be6c 100644 --- a/src/http/ngx_http_request.c +++ b/src/http/ngx_http_request.c @@ -84,7 +84,7 @@ void ngx_http_init_connection(ngx_connection_t *c) rev = c->read; rev->event_handler = ngx_http_init_request; - /* STUB: epoll */ c->write->event_handler = ngx_http_empty_handler; + /* STUB: epoll edge */ c->write->event_handler = ngx_http_empty_handler; if (rev->ready) { /* deferred accept, aio, iocp, epoll */ @@ -1180,6 +1180,8 @@ static void ngx_http_set_keepalive(ngx_http_request_t *r) } h = c->buffer; + wev = c->write; + wev->event_handler = ngx_http_empty_handler; if (h->pos < h->last) { @@ -1214,8 +1216,6 @@ static void ngx_http_set_keepalive(ngx_http_request_t *r) h->pos = h->last = h->start; rev->event_handler = ngx_http_keepalive_handler; - wev = c->write; - wev->event_handler = ngx_http_empty_handler; if (wev->active) { if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) { @@ -1522,7 +1522,7 @@ void ngx_http_close_request(ngx_http_request_t *r, int error) void ngx_http_close_connection(ngx_connection_t *c) { ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, - "close connection: %d", c->fd); + "close http connection: %d", c->fd); if (c->pool == NULL) { ngx_log_error(NGX_LOG_ALERT, c->log, 0, "connection already closed"); diff --git a/src/http/ngx_http_write_filter.c b/src/http/ngx_http_write_filter.c index 271ed17a4..37e8abe88 100644 --- a/src/http/ngx_http_write_filter.c +++ b/src/http/ngx_http_write_filter.c @@ -6,7 +6,7 @@ typedef struct { - ssize_t buffer_output; + ssize_t postpone_output; } ngx_http_write_filter_conf_t; @@ -23,11 +23,19 @@ static int ngx_http_write_filter_init(ngx_cycle_t *cycle); static ngx_command_t ngx_http_write_filter_commands[] = { + /* STUB */ { ngx_string("buffer_output"), NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, ngx_conf_set_size_slot, NGX_HTTP_LOC_CONF_OFFSET, - offsetof(ngx_http_write_filter_conf_t, buffer_output), + offsetof(ngx_http_write_filter_conf_t, postpone_output), + NULL }, + + { ngx_string("postpone_output"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, + ngx_conf_set_size_slot, + NGX_HTTP_LOC_CONF_OFFSET, + offsetof(ngx_http_write_filter_conf_t, postpone_output), NULL }, ngx_null_command @@ -112,21 +120,19 @@ int ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in) } } -#if (NGX_DEBUG_WRITE_FILTER) - ngx_log_debug(r->connection->log, - "write filter: last:%d flush:%qd size:%qd" _ - last _ flush _ size); -#endif + ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "http write filter: l:%d f:" OFF_T_FMT " s:" OFF_T_FMT, + last, flush, size); conf = ngx_http_get_module_loc_conf(r->main ? r->main : r, ngx_http_write_filter_module); /* * avoid the output if there is no last hunk, no flush point and - * the size of the hunks is smaller than "buffer_output" directive + * the size of the hunks is smaller than "postpone_output" directive */ - if (!last && flush == 0 && size < conf->buffer_output) { + if (!last && flush == 0 && size < conf->postpone_output) { return NGX_OK; } @@ -140,9 +146,8 @@ int ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in) chain = ngx_write_chain(r->connection, ctx->out); -#if (NGX_DEBUG_WRITE_FILTER) - ngx_log_debug(r->connection->log, "write filter %x" _ chain); -#endif + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "http write filter %X", chain); if (chain == NGX_CHAIN_ERROR) { return NGX_ERROR; @@ -166,7 +171,7 @@ static void *ngx_http_write_filter_create_conf(ngx_conf_t *cf) ngx_palloc(cf->pool, sizeof(ngx_http_write_filter_conf_t)), NULL); - conf->buffer_output = NGX_CONF_UNSET; + conf->postpone_output = NGX_CONF_UNSET; return conf; } @@ -178,7 +183,8 @@ static char *ngx_http_write_filter_merge_conf(ngx_conf_t *cf, ngx_http_write_filter_conf_t *prev = parent; ngx_http_write_filter_conf_t *conf = child; - ngx_conf_merge_size_value(conf->buffer_output, prev->buffer_output, 1460); + ngx_conf_merge_size_value(conf->postpone_output, prev->postpone_output, + 1460); return NULL; } |
