Author: mdounin Date: 2013-03-29 18:16:27 +0000 (Fri, 29 Mar 2013) New Revision: 5163 URL: http://trac.nginx.org/nginx/changeset/5163/nginx
Log: Merge of r5133, r5134: peer.free() and peer.get() balance. *) Upstream: only call peer.free() if peer.get() selected a peer. *) Upstream: removed double-free workarounds in peer.free() methods. Modified: branches/stable-1.2/ branches/stable-1.2/src/http/modules/ngx_http_upstream_keepalive_module.c branches/stable-1.2/src/http/modules/ngx_http_upstream_least_conn_module.c branches/stable-1.2/src/http/ngx_http_upstream.c branches/stable-1.2/src/http/ngx_http_upstream_round_robin.c Index: branches/stable-1.2 =================================================================== --- branches/stable-1.2 2013-03-29 18:09:06 UTC (rev 5162) +++ branches/stable-1.2 2013-03-29 18:16:27 UTC (rev 5163) Property changes on: branches/stable-1.2 ___________________________________________________________________ Modified: svn:mergeinfo ## -1 +1 ## -/trunk:4611-4632,4636-4657,4671-4672,4674-4676,4682,4684-4699,4704-4706,4713,4736-4741,4754,4756-4771,4775,4777-4780,4782-4785,4795,4811-4820,4822-4824,4828-4835,4840-4844,4865-4872,4885-4887,4890-4896,4913-4925,4933-4934,4939,4944-4949,4961-4969,4973-4974,4976-4994,4997,4999-5005,5011-5025,5027-5031,5066,5070-5071,5078,5082-5083,5098,5109,5113-5114,5117,5123,5127-5132 +/trunk:4611-4632,4636-4657,4671-4672,4674-4676,4682,4684-4699,4704-4706,4713,4736-4741,4754,4756-4771,4775,4777-4780,4782-4785,4795,4811-4820,4822-4824,4828-4835,4840-4844,4865-4872,4885-4887,4890-4896,4913-4925,4933-4934,4939,4944-4949,4961-4969,4973-4974,4976-4994,4997,4999-5005,5011-5025,5027-5031,5066,5070-5071,5078,5082-5083,5098,5109,5113-5114,5117,5123,5127-5134 \ No newline at end of property Modified: branches/stable-1.2/src/http/modules/ngx_http_upstream_keepalive_module.c =================================================================== --- branches/stable-1.2/src/http/modules/ngx_http_upstream_keepalive_module.c 2013-03-29 18:09:06 UTC (rev 5162) +++ branches/stable-1.2/src/http/modules/ngx_http_upstream_keepalive_module.c 2013-03-29 18:16:27 UTC (rev 5163) @@ -37,8 +37,6 @@ ngx_event_save_peer_session_pt original_save_session; #endif - ngx_uint_t failed; /* unsigned:1 */ - } ngx_http_upstream_keepalive_peer_data_t; @@ -220,8 +218,6 @@ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, pc->log, 0, "get keepalive peer"); - kp->failed = 0; - /* ask balancer */ rc = kp->original_get_peer(pc, kp->data); @@ -282,18 +278,12 @@ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, pc->log, 0, "free keepalive peer"); - /* remember failed state - peer.free() may be called more than once */ - - if (state & NGX_PEER_FAILED) { - kp->failed = 1; - } - /* cache valid connections */ u = kp->upstream; c = pc->connection; - if (kp->failed + if (state & NGX_PEER_FAILED || c == NULL || c->read->eof || c->read->error Modified: branches/stable-1.2/src/http/modules/ngx_http_upstream_least_conn_module.c =================================================================== --- branches/stable-1.2/src/http/modules/ngx_http_upstream_least_conn_module.c 2013-03-29 18:09:06 UTC (rev 5162) +++ branches/stable-1.2/src/http/modules/ngx_http_upstream_least_conn_module.c 2013-03-29 18:16:27 UTC (rev 5163) @@ -353,10 +353,6 @@ return; } - if (state == 0 && pc->tries == 0) { - return; - } - lcp->conns[lcp->rrp.current]--; lcp->free_rr_peer(pc, &lcp->rrp, state); Modified: branches/stable-1.2/src/http/ngx_http_upstream.c =================================================================== --- branches/stable-1.2/src/http/ngx_http_upstream.c 2013-03-29 18:09:06 UTC (rev 5162) +++ branches/stable-1.2/src/http/ngx_http_upstream.c 2013-03-29 18:16:27 UTC (rev 5163) @@ -2846,14 +2846,16 @@ ngx_http_busy_unlock(u->conf->busy_lock, &u->busy_lock); #endif - if (ft_type == NGX_HTTP_UPSTREAM_FT_HTTP_404) { - state = NGX_PEER_NEXT; - } else { - state = NGX_PEER_FAILED; - } + if (u->peer.sockaddr) { - if (ft_type != NGX_HTTP_UPSTREAM_FT_NOLIVE) { + if (ft_type == NGX_HTTP_UPSTREAM_FT_HTTP_404) { + state = NGX_PEER_NEXT; + } else { + state = NGX_PEER_FAILED; + } + u->peer.free(&u->peer, u->peer.data, state); + u->peer.sockaddr = NULL; } if (ft_type == NGX_HTTP_UPSTREAM_FT_TIMEOUT) { @@ -3013,8 +3015,9 @@ u->finalize_request(r, rc); - if (u->peer.free) { + if (u->peer.free && u->peer.sockaddr) { u->peer.free(&u->peer, u->peer.data, 0); + u->peer.sockaddr = NULL; } if (u->peer.connection) { Modified: branches/stable-1.2/src/http/ngx_http_upstream_round_robin.c =================================================================== --- branches/stable-1.2/src/http/ngx_http_upstream_round_robin.c 2013-03-29 18:09:06 UTC (rev 5162) +++ branches/stable-1.2/src/http/ngx_http_upstream_round_robin.c 2013-03-29 18:16:27 UTC (rev 5163) @@ -584,10 +584,6 @@ ngx_log_debug2(NGX_LOG_DEBUG_HTTP, pc->log, 0, "free rr peer %ui %ui", pc->tries, state); - if (state == 0 && pc->tries == 0) { - return; - } - /* TODO: NGX_PEER_KEEPALIVE */ if (rrp->peers->single) { _______________________________________________ nginx-devel mailing list nginx-devel@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx-devel