nginx-0.0.1-2003-11-05-20:03:41 import
diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.c b/src/http/modules/proxy/ngx_http_proxy_handler.c
index 860ba7a..a284956 100644
--- a/src/http/modules/proxy/ngx_http_proxy_handler.c
+++ b/src/http/modules/proxy/ngx_http_proxy_handler.c
@@ -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() */