mirror of
https://github.com/nginx/nginx.git
synced 2024-12-13 02:39:00 +08:00
Upstream: removed double-free workarounds in peer.free() methods.
This commit is contained in:
parent
46b469a8ee
commit
2fd8b271c4
@ -37,8 +37,6 @@ typedef struct {
|
|||||||
ngx_event_save_peer_session_pt original_save_session;
|
ngx_event_save_peer_session_pt original_save_session;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ngx_uint_t failed; /* unsigned:1 */
|
|
||||||
|
|
||||||
} ngx_http_upstream_keepalive_peer_data_t;
|
} 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,
|
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, pc->log, 0,
|
||||||
"get keepalive peer");
|
"get keepalive peer");
|
||||||
|
|
||||||
kp->failed = 0;
|
|
||||||
|
|
||||||
/* ask balancer */
|
/* ask balancer */
|
||||||
|
|
||||||
rc = kp->original_get_peer(pc, kp->data);
|
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,
|
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, pc->log, 0,
|
||||||
"free keepalive peer");
|
"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 */
|
/* cache valid connections */
|
||||||
|
|
||||||
u = kp->upstream;
|
u = kp->upstream;
|
||||||
c = pc->connection;
|
c = pc->connection;
|
||||||
|
|
||||||
if (kp->failed
|
if (state & NGX_PEER_FAILED
|
||||||
|| c == NULL
|
|| c == NULL
|
||||||
|| c->read->eof
|
|| c->read->eof
|
||||||
|| c->read->error
|
|| c->read->error
|
||||||
|
@ -353,10 +353,6 @@ ngx_http_upstream_free_least_conn_peer(ngx_peer_connection_t *pc,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state == 0 && pc->tries == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
lcp->conns[lcp->rrp.current]--;
|
lcp->conns[lcp->rrp.current]--;
|
||||||
|
|
||||||
lcp->free_rr_peer(pc, &lcp->rrp, state);
|
lcp->free_rr_peer(pc, &lcp->rrp, state);
|
||||||
|
@ -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,
|
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, pc->log, 0,
|
||||||
"free rr peer %ui %ui", pc->tries, state);
|
"free rr peer %ui %ui", pc->tries, state);
|
||||||
|
|
||||||
if (state == 0 && pc->tries == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* TODO: NGX_PEER_KEEPALIVE */
|
/* TODO: NGX_PEER_KEEPALIVE */
|
||||||
|
|
||||||
if (rrp->peers->single) {
|
if (rrp->peers->single) {
|
||||||
|
Loading…
Reference in New Issue
Block a user