]> git.kaiwu.me - nginx.git/commitdiff
Upstream: removed double-free workarounds in peer.free() methods.
authorRuslan Ermilov <ru@nginx.com>
Mon, 25 Mar 2013 13:16:55 +0000 (13:16 +0000)
committerRuslan Ermilov <ru@nginx.com>
Mon, 25 Mar 2013 13:16:55 +0000 (13:16 +0000)
src/http/modules/ngx_http_upstream_keepalive_module.c
src/http/modules/ngx_http_upstream_least_conn_module.c
src/http/ngx_http_upstream_round_robin.c

index a2ad5aa8d952f401df615fd79edb8fa56cb35a27..eed117404f4c0099113829366fc85292c402564c 100644 (file)
@@ -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_peer_connection_t *pc, void *data)
     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(ngx_peer_connection_t *pc, void *data,
     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
index bd2f1bc9e7f40b2ca95317eea540279525c70948..6066ed2bb84d9b9d838c05f61a48b8d085ec792e 100644 (file)
@@ -353,10 +353,6 @@ ngx_http_upstream_free_least_conn_peer(ngx_peer_connection_t *pc,
         return;
     }
 
-    if (state == 0 && pc->tries == 0) {
-        return;
-    }
-
     lcp->conns[lcp->rrp.current]--;
 
     lcp->free_rr_peer(pc, &lcp->rrp, state);
index b4803941400519de44c86e1208c71d7bafbbd83e..ec7b2897e30e7daac5f7fe7d117ae11bde3e379f 100644 (file)
@@ -584,10 +584,6 @@ ngx_http_upstream_free_round_robin_peer(ngx_peer_connection_t *pc, void *data,
     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) {