Skip to content

Commit 60ebb5c

Browse files
committed
bugfix: hot loop might happen when balancer_by_lua was used with the "keepalive" directive. thanks GhostZch for the report in openresty#693.
1 parent 6a422b6 commit 60ebb5c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/ngx_http_lua_balancer.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ ngx_http_lua_balancer_get_peer(ngx_peer_connection_t *pc, void *data)
254254
ngx_http_lua_balancer_peer_data_t *bp = data;
255255

256256
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
257-
"lua balancer peer, try: %ui", pc->tries);
257+
"lua balancer peer, tries: %ui", pc->tries);
258258

259259
lscf = bp->conf;
260260

@@ -315,6 +315,9 @@ ngx_http_lua_balancer_get_peer(ngx_peer_connection_t *pc, void *data)
315315
pc->sockaddr = bp->sockaddr;
316316
pc->socklen = bp->socklen;
317317
pc->name = &bp->host;
318+
pc->cached = 0;
319+
pc->connection = NULL;
320+
318321
bp->rrp.peers->single = 0;
319322

320323
if (bp->more_tries) {
@@ -388,6 +391,9 @@ ngx_http_lua_balancer_free_peer(ngx_peer_connection_t *pc, void *data,
388391
{
389392
ngx_http_lua_balancer_peer_data_t *bp = data;
390393

394+
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
395+
"lua balancer free peer, tries: %ui", pc->tries);
396+
391397
if (bp->sockaddr && bp->socklen) {
392398
bp->last_peer_state = (int) state;
393399

0 commit comments

Comments
 (0)