Skip to content

Detach socket - #2560

Open
zhuizhuhaomeng wants to merge 12 commits into
masterfrom
detach-socket
Open

zhuizhuhaomeng wants to merge 12 commits into
masterfrom
detach-socket

Conversation

@zhuizhuhaomeng

Copy link
Copy Markdown
Contributor

I hereby granted the copyright of the changes in this pull request
to the authors of this lua-nginx-module project.

Canceling a pending read could leave the request pointing to socket
userdata after Lua collected it. Clear the downstream reference and
restore the read event handler when finalizing the socket.

Wake a pending duplex operation with a closed error and preserve any
partial input. Add regression tests for canceling either operation,
canceling both before wakeup, and canceling a request body read.
A subrequest can change the connection's log context before the close
timer resumes a pending socket operation. Restore the owning request
before resuming the coroutine so its messages identify the right
request.

Verify log attribution while a subrequest is active and exercise
client abort monitoring after a body read is canceled. Buffer the
expected partial input before canceling the writer so the test also
covers one-byte reads.
Exercise partial uploads, internal redirects, raw socket takeover, and
HTTP keepalive after a pending reader is canceled.

Check TLS shutdown at the pipeline buffer limit and use an OpenSSL
client to verify that pipelined TLS 1.3 early data survives cancellation.
Reading ahead into a large header buffer consumed a slot needed by the
next request and could make nginx reject a valid header. Keep the bytes
on the connection so the HTTP parser, raw sockets, and upgraded proxies
can read them with the configured header limits intact.

Close unfinished uploads on older nginx versions and report local read
errors separately from client disconnects. Cover header limits, socket
handoff, and TLS shutdown, and gate the OpenSSL early-data test on
nginx 1.15.4 or later.
Let Test::Nginx count the assertions that run. The previous plans
included assertions from other blocks when a developer selected a
single case with the ONLY directive.
Keep the monitor read buffer on the connection and defer response writes
and keepalive handoff while OpenSSL has a suspended read. Pass saved
input to the next HTTP reader in order.

Exercise read completion before and after a response write, request
finalization, and abort at the pipeline buffer boundary. Synchronize the
raw socket disconnect test with the server before closing the client.
An SSL read can pause before the Lua coroutine that started it is
canceled. Use a connection-owned buffer for reads that can pause,
and drain the remaining request body before sizing pipeline read-ahead.

Cover normal completion and cancellation for raw and body sockets,
including concurrent writes and keepalive reuse. Use the configured
OpenSSL paths when building the async and early-data test fixtures.
Deferred accept can deliver a request before nginx registers its read
event. Use the trigger mode of the event backend in all five Lua phases so
unread pipelined data does not repeatedly wake an epoll worker. Add a
regression test that checks the upload connection for EPOLLET.

Include ngx_ssl_engine.h only when the core still needs it to define
ngx_ssl_waiting_for_async. Intel asynch_mode_nginx v0.3.1 already
provides the macro in its OpenSSL header.
When TEST_NGINX_EVENT_TYPE is unset, read the event method from the
nginx startup log. This lets the deferred-accept and async TLS tests
skip their epoll checks when nginx falls back to select on Linux.

Verified automatic fallback to select, explicit select and poll, and
both default and explicit epoll. The deferred-accept assertion still
detects the original registration bug on the previous nginx binary.
Give both probes a PID file under their temporary nginx prefix and
use the worker credentials selected by Test::Nginx. This lets the
probes start when the compiled-in PID path is unwritable or the
default service account is absent.

Verified both request socket suites as an unprivileged user and under
fakeroot, including an async TLS run with an explicit user and group.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant