diff src/http/modules/ngx_http_upstream_keepalive_module.c @ 5162:ee9a043765ea stable-1.2

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.
author Maxim Dounin <mdounin@mdounin.ru>
date Fri, 29 Mar 2013 18:16:27 +0000
parents 63bc961253eb
children 822b82191940
line wrap: on
line diff
--- a/src/http/modules/ngx_http_upstream_keepalive_module.c
+++ b/src/http/modules/ngx_http_upstream_keepalive_module.c
@@ -37,8 +37,6 @@ typedef struct {
     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_http_upstream_get_keepalive_peer(ngx
     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_http_upstream_free_keepalive_peer(ng
     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