# HG changeset patch # User Igor Sysoev # Date 1072086048 0 # Node ID e0c502f15852ece7ee100ec7f35835112a8736b9 # Parent f536f91e8e9996741b536623b1793ac9dc870360 nginx-0.0.1-2003-12-22-12:40:48 import diff --git a/src/core/ngx_log.h b/src/core/ngx_log.h --- a/src/core/ngx_log.h +++ b/src/core/ngx_log.h @@ -207,6 +207,23 @@ void ngx_assert_core(ngx_log_t *log, con #endif #if (NGX_DEBUG) +#define ngx_log_debug4(level, log, err, fmt, arg1, arg2, arg3, arg4) \ + if (log->log_level & level) \ + ngx_log_error_core(NGX_LOG_DEBUG, log, err, fmt, arg1, arg2, arg3, arg4) +#else +#define ngx_log_debug4(level, log, err, fmt, arg1, arg2, arg3, arg4) +#endif + +#if (NGX_DEBUG) +#define ngx_log_debug5(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5) \ + if (log->log_level & level) \ + ngx_log_error_core(NGX_LOG_DEBUG, log, err, fmt, \ + arg1, arg2, arg3, arg4, arg5) +#else +#define ngx_log_debug5(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5) +#endif + +#if (NGX_DEBUG) #define ngx_log_debug6(level, log, err, fmt, \ arg1, arg2, arg3, arg4, arg5, arg6) \ if (log->log_level & level) \ @@ -253,6 +270,22 @@ void ngx_assert_core(ngx_log_t *log, con #endif #if (NGX_DEBUG) +#define ngx_log_debug4(level, log, err, fmt, arg1, arg2, arg3, arg4) \ + if (log->log_level & level) \ + ngx_log_debug_core(log, err, fmt, arg1, arg2, arg3, arg4) +#else +#define ngx_log_debug4(level, log, err, fmt, arg1, arg2, arg3, arg4) +#endif + +#if (NGX_DEBUG) +#define ngx_log_debug5(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5) \ + if (log->log_level & level) \ + ngx_log_debug_core(log, err, fmt, arg1, arg2, arg3, arg4, arg5) +#else +#define ngx_log_debug5(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5) +#endif + +#if (NGX_DEBUG) #define ngx_log_debug6(level, log, err, fmt, \ arg1, arg2, arg3, arg4, arg5, arg6) \ if (log->log_level & level) \ diff --git a/src/event/ngx_event_timer.h b/src/event/ngx_event_timer.h --- a/src/event/ngx_event_timer.h +++ b/src/event/ngx_event_timer.h @@ -33,15 +33,24 @@ extern ngx_rbtree_t *ngx_event_timer_rb extern ngx_rbtree_t ngx_event_timer_sentinel; +#define ngx_event_ident(p) ((ngx_connection_t *) (p))->fd + ngx_inline static void ngx_event_del_timer(ngx_event_t *ev) { - ngx_log_debug1(NGX_LOG_DEBUG_EVENT, ev->log, 0, - "event timer del: %d", ev->rbtree_key); + ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0, + "event timer del: %d: %d", + ngx_event_ident(ev->data), ev->rbtree_key); ngx_rbtree_delete(&ngx_event_timer_rbtree, &ngx_event_timer_sentinel, (ngx_rbtree_t *) &ev->rbtree_key); +#if (NGX_DEBUG) + ev->rbtree_left = NULL; + ev->rbtree_right = NULL; + ev->rbtree_parent = NULL; +#endif + ev->timer_set = 0; } @@ -59,8 +68,9 @@ ngx_inline static void ngx_event_add_tim (ngx_elapsed_msec + timer) / NGX_TIMER_RESOLUTION; #endif - ngx_log_debug1(NGX_LOG_DEBUG_EVENT, ev->log, 0, - "event timer add: %d", ev->rbtree_key); + ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0, + "event timer add: %d: %d", + ngx_event_ident(ev->data), ev->rbtree_key); ngx_rbtree_insert(&ngx_event_timer_rbtree, &ngx_event_timer_sentinel, (ngx_rbtree_t *) &ev->rbtree_key); diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c --- a/src/http/ngx_http_request.c +++ b/src/http/ngx_http_request.c @@ -657,6 +657,24 @@ static void ngx_http_process_request_hea /* there was error while a header line parsing */ +#if (NGX_LOG_DEBUG) + if (rc == NGX_HTTP_PARSE_INVALID_HEADER) { + char *p; + for (p = r->header_name_start; + p < r->header_in->last - 1; + p++) + { + if (*p == CR || *p == LF) { + break; + } + } + *p = '\0'; + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, rev->log, 0, + "http invalid header: \"%s\"", + r->header_name_start); + } +#endif + ngx_http_client_error(r, rc, NGX_HTTP_BAD_REQUEST); return; } @@ -1419,7 +1437,7 @@ void ngx_http_close_request(ngx_http_req return; } - if (error) { + if (error && r->headers_out.status == 0) { r->headers_out.status = error; } diff --git a/src/os/unix/ngx_freebsd_sendfile_chain.c b/src/os/unix/ngx_freebsd_sendfile_chain.c --- a/src/os/unix/ngx_freebsd_sendfile_chain.c +++ b/src/os/unix/ngx_freebsd_sendfile_chain.c @@ -44,7 +44,7 @@ ngx_chain_t *ngx_freebsd_sendfile_chain( #if (HAVE_KQUEUE) if ((ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) && wev->kq_eof) { - ngx_log_error(NGX_LOG_ERR, c->log, wev->kq_errno, + ngx_log_error(NGX_LOG_INFO, c->log, wev->kq_errno, "kevent() reported about closed connection"); wev->error = 1; @@ -153,7 +153,7 @@ ngx_chain_t *ngx_freebsd_sendfile_chain( if (ngx_freebsd_use_tcp_nopush && !c->tcp_nopush) { c->tcp_nopush = 1; -ngx_log_debug(c->log, "NOPUSH"); + ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, "tcp_nopush"); if (ngx_tcp_nopush(c->fd) == NGX_ERROR) { ngx_log_error(NGX_LOG_CRIT, c->log, ngx_errno, @@ -193,9 +193,9 @@ ngx_log_debug(c->log, "NOPUSH"); } if (err == NGX_EAGAIN || err == NGX_EINTR) { - ngx_log_error(NGX_LOG_INFO, c->log, err, - "sendfile() sent only " OFF_T_FMT " bytes", - sent); + ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, err, + "sendfile() sent only " OFF_T_FMT " bytes", + sent); } else { wev->error = 1; @@ -205,22 +205,23 @@ ngx_log_debug(c->log, "NOPUSH"); } } -#if (NGX_DEBUG_WRITE_CHAIN) - ngx_log_debug(c->log, "sendfile: %d, @%qd %qd:%d" _ - rc _ file->file_pos _ sent _ fsize + hsize); -#endif + ngx_log_debug4(NGX_LOG_DEBUG_EVENT, c->log, 0, + "sendfile: %d, @" OFF_T_FMT " " OFF_T_FMT ":%d", + rc, file->file_pos, sent, fsize + hsize); } else { rc = writev(c->fd, header.elts, header.nelts); if (rc == -1) { err = ngx_errno; - if (err == NGX_EAGAIN) { - ngx_log_error(NGX_LOG_INFO, c->log, err, "writev() EAGAIN"); - } else if (err == NGX_EINTR) { + if (err == NGX_EINTR) { eintr = 1; - ngx_log_error(NGX_LOG_INFO, c->log, err, "writev() EINTR"); + } + + if (err == NGX_EAGAIN || err == NGX_EINTR) { + ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, err, + "writev() not ready"); } else { wev->error = 1; @@ -231,9 +232,8 @@ ngx_log_debug(c->log, "NOPUSH"); sent = rc > 0 ? rc : 0; -#if (NGX_DEBUG_WRITE_CHAIN) - ngx_log_debug(c->log, "writev: %qd" _ sent); -#endif + ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, + "writev: " OFF_T_FMT, sent); } c->sent += sent;