diff options
| author | Igor Sysoev <igor@sysoev.ru> | 2004-02-11 17:08:49 +0000 |
|---|---|---|
| committer | Igor Sysoev <igor@sysoev.ru> | 2004-02-11 17:08:49 +0000 |
| commit | 54498db7a2a2e7e74fba61ec073b248da05e999e (patch) | |
| tree | 7e5bda151896efa349f2220fc122ba9792ce5dfb /src/http/modules/proxy | |
| parent | c7a2f6860669f45f5abe342163de5bc68e344816 (diff) | |
| download | nginx-54498db7a2a2e7e74fba61ec073b248da05e999e.tar.gz nginx-54498db7a2a2e7e74fba61ec073b248da05e999e.tar.bz2 | |
nginx-0.0.2-2004-02-11-20:08:49 import
Diffstat (limited to 'src/http/modules/proxy')
| -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 |
3 files changed, 69 insertions, 59 deletions
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); |
