diff options
author | Igor Sysoev <igor@sysoev.ru> | 2003-11-25 20:44:56 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2003-11-25 20:44:56 +0000 |
commit | a8fa0a6a37b6e90324e0dcbf4733324199623841 (patch) | |
tree | 1a7edec9aa04946afc22299bf587823488fb492f /src/http/modules/proxy | |
parent | d9d0ca12688034d481e2f1f5cf13a098338ec31d (diff) | |
download | nginx-a8fa0a6a37b6e90324e0dcbf4733324199623841.tar.gz nginx-a8fa0a6a37b6e90324e0dcbf4733324199623841.zip |
nginx-0.0.1-2003-11-25-23:44:56 import
Diffstat (limited to 'src/http/modules/proxy')
-rw-r--r-- | src/http/modules/proxy/ngx_http_proxy_cache.c | 5 | ||||
-rw-r--r-- | src/http/modules/proxy/ngx_http_proxy_handler.c | 32 | ||||
-rw-r--r-- | src/http/modules/proxy/ngx_http_proxy_upstream.c | 21 |
3 files changed, 44 insertions, 14 deletions
diff --git a/src/http/modules/proxy/ngx_http_proxy_cache.c b/src/http/modules/proxy/ngx_http_proxy_cache.c index 05fec3a19..9661cff96 100644 --- a/src/http/modules/proxy/ngx_http_proxy_cache.c +++ b/src/http/modules/proxy/ngx_http_proxy_cache.c @@ -86,6 +86,7 @@ static int ngx_http_proxy_process_cached_response(ngx_http_proxy_ctx_t *p, } if (rc == NGX_HTTP_CACHE_STALE || rc == NGX_HTTP_CACHE_AGED) { + p->state->expired = ngx_time() - p->cache->ctx.expires; p->header_in->pos = p->header_in->start + p->cache->ctx.header_size; if (ngx_http_proxy_process_cached_header(p) == NGX_ERROR) { @@ -487,6 +488,8 @@ int ngx_http_proxy_send_cached_response(ngx_http_proxy_ctx_t *p) out[i].hunk->type |= NGX_HUNK_LAST; } + r->file.fd = p->cache->ctx.file.fd; + return ngx_http_output_filter(r, out); } @@ -600,7 +603,7 @@ 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_FMT ", " OFF_FMT _ +ngx_log_debug(p->request->connection->log, "LEN: " OFF_T_FMT ", " OFF_T_FMT _ p->cache->ctx.length _ ep->read_length); if (p->cache->ctx.length == -1) { diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.c b/src/http/modules/proxy/ngx_http_proxy_handler.c index 25f5b3371..e8b78f498 100644 --- a/src/http/modules/proxy/ngx_http_proxy_handler.c +++ b/src/http/modules/proxy/ngx_http_proxy_handler.c @@ -485,6 +485,10 @@ ngx_log_debug(r->connection->log, "CACHE FD: %d" _ p->cache->ctx.file.fd); r->file.fd = p->cache->ctx.file.fd; } + if (rc == 0 && r->main == NULL) { + rc = ngx_http_send_last(r); + } + ngx_http_finalize_request(r, rc); } @@ -586,15 +590,25 @@ static char *ngx_http_proxy_log_proxy_state(ngx_http_request_t *r, char *buf, *buf++ = '/'; - *buf++ = '_'; + if (p->state->expired == 0) { + *buf++ = '-'; + + } else { + buf += ngx_snprintf(buf, NGX_TIME_LEN, TIME_T_FMT, p->state->expired); + } *buf++ = '/'; - *buf++ = '_'; + if (p->state->bl_time == 0) { + *buf++ = '-'; + + } else { + buf += ngx_snprintf(buf, NGX_TIME_LEN, TIME_T_FMT, p->state->bl_time); + } *buf++ = '/'; - *buf++ = '_'; + *buf++ = '*'; *buf++ = ' '; @@ -617,15 +631,15 @@ static char *ngx_http_proxy_log_proxy_state(ngx_http_request_t *r, char *buf, *buf++ = '/'; - if (p->state->reason >= NGX_HTTP_PROXY_CACHE_XAE) { + if (p->state->reason < NGX_HTTP_PROXY_CACHE_XAE) { *buf++ = '-'; } else { - buf += ngx_snprintf(buf, NGX_TIME_LEN, TIME_FMT, p->state->expires); + buf += ngx_snprintf(buf, NGX_TIME_LEN, TIME_T_FMT, p->state->expires); } *buf++ = ' '; - *buf++ = '_'; + *buf++ = '*'; return buf; } @@ -833,9 +847,9 @@ static char *ngx_http_proxy_set_pass(ngx_conf_t *cf, ngx_command_t *cmd, int i, len; char *err, *host; + in_addr_t addr; ngx_str_t *value; struct hostent *h; - u_int32_t addr; ngx_http_conf_ctx_t *ctx; ngx_http_core_loc_conf_t *clcf; @@ -869,6 +883,8 @@ static char *ngx_http_proxy_set_pass(ngx_conf_t *cf, ngx_command_t *cmd, NGX_CONF_ERROR); ngx_cpystrn(host, lcf->upstream->host.data, lcf->upstream->host.len + 1); + /* AF_INET only */ + addr = inet_addr(host); if (addr == INADDR_NONE) { @@ -894,7 +910,7 @@ static char *ngx_http_proxy_set_pass(ngx_conf_t *cf, ngx_command_t *cmd, for (i = 0; h->h_addr_list[i] != NULL; i++) { lcf->peers->peers[i].host.data = host; lcf->peers->peers[i].host.len = lcf->upstream->host.len; - lcf->peers->peers[i].addr = *(u_int32_t *)(h->h_addr_list[i]); + lcf->peers->peers[i].addr = *(in_addr_t *)(h->h_addr_list[i]); lcf->peers->peers[i].port = lcf->upstream->port; len = INET_ADDRSTRLEN + lcf->upstream->port_text.len + 1; diff --git a/src/http/modules/proxy/ngx_http_proxy_upstream.c b/src/http/modules/proxy/ngx_http_proxy_upstream.c index 1b1ca4493..d36cbee10 100644 --- a/src/http/modules/proxy/ngx_http_proxy_upstream.c +++ b/src/http/modules/proxy/ngx_http_proxy_upstream.c @@ -1017,8 +1017,7 @@ static void ngx_http_proxy_send_response(ngx_http_proxy_ctx_t *p) ep->hunk_to_file->type = NGX_HUNK_IN_MEMORY|NGX_HUNK_TEMP; if (ngx_event_flags & NGX_USE_AIO_EVENT) { - - /* the posted aio operation can currupt shadow buf */ + /* the posted aio operation can currupt a shadow buffer */ ep->single_buf = 1; } @@ -1126,26 +1125,38 @@ 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_http_busy_unlock(p->lcf->busy_lock, &p->busy_lock); - ngx_http_proxy_close_connection(p); + 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_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, r->main ? 0 : ngx_http_send_last(r)); + 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_connection(r->connection); + ngx_http_close_request(r); } } +#endif } |