Open
Conversation
Introduces the peek(N) method for UDP request sockets in the preread phase, allowing inspection of N bytes from the preread buffer without consuming them. Updates the UDP socket implementation, metatable, and state tracking to support this feature. Adds documentation and comprehensive tests for UDP socket peek behavior, including error and edge cases.
Replaces the coroutine cleanup handler from ngx_stream_lua_coctx_cleanup to ngx_stream_lua_udp_socket_cleanup in ngx_stream_lua_req_socket_udp_peek. This ensures proper cleanup specific to UDP socket operations when yielding due to insufficient preread buffer data.
Added a check for NULL buffer before calculating the size in ngx_stream_lua_req_socket_udp_peek_resume to prevent potential null pointer dereference.
Introduces additional debug logging when the UDP socket peek() method is called and updates an existing log message for clarity. This helps with tracing and debugging UDP socket operations in the stream lua module.
zhuizhuhaomeng
requested changes
Sep 1, 2025
| r->connection->buffer->pos, u->received); | ||
| r->connection->buffer->pos += u->received; | ||
|
|
||
| u->read_consumed = 1; |
Contributor
There was a problem hiding this comment.
If there are multiple udp packets in the same stream, will peak available in every packet?
616f118 to
cd24241
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
reqsock:peekfor UDP preread sockets