Skip to content

Commit 3f897a7

Browse files
committed
synchronized with lua-nginx-module #f64ec8c.
bugfix: tcpsock:setkeepalive: worker processes might take too long to gracefully shut down when the keep alive connections take a long max idle time. Now we avoid putting any new connections into the pool when nginx is already shutting down. Thanks Dejiang Zhu for the upstream patch.
1 parent 545efef commit 3f897a7

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/subsys/ngx_subsys_lua_socket_tcp.c.tt2

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5266,6 +5266,14 @@ ngx_[% subsys %]_lua_socket_tcp_setkeepalive(lua_State *L)
52665266
return 2;
52675267
}
52685268

5269+
if (ngx_terminate || ngx_exiting) {
5270+
ngx_log_debug1(NGX_LOG_DEBUG_[% SUBSYS %], pc->log, 0,
5271+
"[% log_prefix %]lua tcp socket set keepalive while "
5272+
"process exiting, closing connection %p", c);
5273+
5274+
goto finalize;
5275+
}
5276+
52695277
ngx_log_debug1(NGX_LOG_DEBUG_[% SUBSYS %], pc->log, 0,
52705278
"[% log_prefix %]lua tcp socket set keepalive: saving "
52715279
"connection %p", c);
@@ -5435,6 +5443,8 @@ ngx_[% subsys %]_lua_socket_tcp_setkeepalive(lua_State *L)
54355443
}
54365444
}
54375445

5446+
finalize:
5447+
54385448
#if 1
54395449
ngx_[% subsys %]_lua_socket_tcp_finalize(r, u);
54405450
#endif

0 commit comments

Comments
 (0)