Repository navigation
Commit d701ffa
committed
change: hand cosocket connections directly to waiting operations.
Port the direct handoff of openresty/lua-nginx-module#2544 (b965a88,
fbbcf41 and 3e21572) to the stream module, replacing the reserved queue
and the next_connect_op cursor.
A pool counts the slots it handed out, to active sockets, cached idle
connections and posted connect operations, in connections, and the
operations still queued, which hold no slot, in waiting; the backlog
check is on waiting. Posted operations move to their own
posted_connect_op queue. When setkeepalive() returns a connection while
someone waits, the connection is attached to the head waiter instead of
going to the cache, and the waiter takes it when its resumption runs.
Every place that frees a slot goes through
ngx_stream_lua_socket_tcp_release_slot(), which resumes the next waiter
with the slot and the connection, if any, or puts the connection in the
cache or decrements the count.
As in #2544, a queued or posted socket stays busy connecting and its
pool key is written only once the busy checks pass; a failed connect
closes a partly set up peer and releases its slot once; a connection
made before the pool existed only replaces an idle connection in a full
pool; and a posted operation cancelled by a light thread kill, the end
of its timer or session, or a request cleanup releases its slot.1 parent aa0ba51 commit d701ffa
2 files changed
Lines changed: 360 additions & 363 deletions
0 commit comments