Skip to content

Commit 131b3c0

Browse files
author
ru
committed
Upstream: removed double-free workarounds in peer.free() methods.
1 parent b46fcd7 commit 131b3c0

File tree

3 files changed

+1
-19
lines changed

3 files changed

+1
-19
lines changed

src/http/modules/ngx_http_upstream_keepalive_module.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ typedef struct {
3737
ngx_event_save_peer_session_pt original_save_session;
3838
#endif
3939

40-
ngx_uint_t failed; /* unsigned:1 */
41-
4240
} ngx_http_upstream_keepalive_peer_data_t;
4341

4442

@@ -220,8 +218,6 @@ ngx_http_upstream_get_keepalive_peer(ngx_peer_connection_t *pc, void *data)
220218
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, pc->log, 0,
221219
"get keepalive peer");
222220

223-
kp->failed = 0;
224-
225221
/* ask balancer */
226222

227223
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,
282278
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, pc->log, 0,
283279
"free keepalive peer");
284280

285-
/* remember failed state - peer.free() may be called more than once */
286-
287-
if (state & NGX_PEER_FAILED) {
288-
kp->failed = 1;
289-
}
290-
291281
/* cache valid connections */
292282

293283
u = kp->upstream;
294284
c = pc->connection;
295285

296-
if (kp->failed
286+
if (state & NGX_PEER_FAILED
297287
|| c == NULL
298288
|| c->read->eof
299289
|| c->read->error

src/http/modules/ngx_http_upstream_least_conn_module.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -353,10 +353,6 @@ ngx_http_upstream_free_least_conn_peer(ngx_peer_connection_t *pc,
353353
return;
354354
}
355355

356-
if (state == 0 && pc->tries == 0) {
357-
return;
358-
}
359-
360356
lcp->conns[lcp->rrp.current]--;
361357

362358
lcp->free_rr_peer(pc, &lcp->rrp, state);

src/http/ngx_http_upstream_round_robin.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -584,10 +584,6 @@ ngx_http_upstream_free_round_robin_peer(ngx_peer_connection_t *pc, void *data,
584584
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, pc->log, 0,
585585
"free rr peer %ui %ui", pc->tries, state);
586586

587-
if (state == 0 && pc->tries == 0) {
588-
return;
589-
}
590-
591587
/* TODO: NGX_PEER_KEEPALIVE */
592588

593589
if (rrp->peers->single) {

0 commit comments

Comments
 (0)