Mercurial > hg > nginx
diff src/http/modules/proxy/ngx_http_proxy_handler.c @ 175:e92c2c647c57
nginx-0.0.1-2003-11-05-20:03:41 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 05 Nov 2003 17:03:41 +0000 |
parents | ea464a6c0581 |
children | c0552e5ab567 |
line wrap: on
line diff
--- a/src/http/modules/proxy/ngx_http_proxy_handler.c Tue Nov 04 22:12:39 2003 +0000 +++ b/src/http/modules/proxy/ngx_http_proxy_handler.c Wed Nov 05 17:03:41 2003 +0000 @@ -266,7 +266,9 @@ ngx_memzero(p->state, sizeof(ngx_http_proxy_state_t)); - if (!p->lcf->cache) { + if (!p->lcf->cache + || (r->method != NGX_HTTP_GET && r->method != NGX_HTTP_HEAD)) + { p->state->cache = NGX_HTTP_PROXY_CACHE_PASS; } else if (r->bypass_cache) { @@ -290,16 +292,16 @@ rc = ngx_http_proxy_get_cached_response(p); + if (rc == NGX_DONE || rc == NGX_HTTP_INTERNAL_SERVER_ERROR) { + return rc; + } + p->valid_header_in = 1; if (rc == NGX_OK) { return ngx_http_proxy_send_cached_response(p); } - if (rc == NGX_HTTP_INTERNAL_SERVER_ERROR) { - return rc; - } - /* rc == NGX_DECLINED || NGX_HTTP_CACHE_STALE || NGX_HTTP_CACHE_AGED */ return ngx_http_proxy_request_upstream(p); @@ -312,8 +314,7 @@ "finalize http proxy request"); if (p->upstream->peer.connection) { - ngx_http_proxy_close_connection(p->upstream->peer.connection); - p->upstream->peer.connection = NULL; + ngx_http_proxy_close_connection(p); } if (p->header_sent @@ -329,8 +330,17 @@ } -void ngx_http_proxy_close_connection(ngx_connection_t *c) +void ngx_http_proxy_close_connection(ngx_http_proxy_ctx_t *p) { + ngx_connection_t *c; + + c = p->upstream->peer.connection; + p->upstream->peer.connection = NULL; + + if (p->lcf->busy_lock) { + p->lcf->busy_lock->conn_n--; + } + ngx_log_debug(c->log, "proxy close connection: %d" _ c->fd); if (c->fd == -1) { @@ -505,6 +515,13 @@ if (conf->busy_lock && conf->cache && conf->busy_lock->busy == NULL) { + /* ngx_alloc_shared() */ + conf->busy_lock->busy_mask = + ngx_palloc(cf->pool, (conf->busy_lock->max_conn + 7) / 8); + if (conf->busy_lock->busy_mask == NULL) { + return NGX_CONF_ERROR; + } + /* 16 bytes are 128 bits of the md5 */ /* ngx_alloc_shared() */