check nginx daemon state before setting new event timer#11
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds guard checks for NGINX shutdown flags before scheduling event timers in the Unix socket logic and introduces a new uri_method accessor in HTTP requests.
- Added conditional guards (
ngx_quit,ngx_exiting,ngx_terminate, andtimer_set) aroundngx_event_add_timercalls in several places to prevent scheduling timers during shutdown or if already set. - Exposed HTTP method name via a new
pub fn uri_method(&self) -> NgxStrinHttpRequest.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| unix_socket.rs | Wrapped ngx_event_add_timer calls with shutdown and timer_set checks in three places |
| http_request.rs | Added a new public uri_method method returning NgxStr from the native method_name |
Comments suppressed due to low confidence (2)
nginx_module/src/http_request.rs:303
- [nitpick] The name
uri_methodmay be misleading since it returns the HTTP method (e.g., GET or POST), not a URI. Consider renaming tohttp_methodor simplymethodfor clarity.
pub fn uri_method(&self) -> NgxStr {
nginx_module/src/http_request.rs:303
- [nitpick] This new public method lacks a doc comment. Please add a brief description and example usage in the module’s documentation to maintain consistency.
pub fn uri_method(&self) -> NgxStr {
Comment on lines
+86
to
+92
| if (*ev).timer_set() == 0 | ||
| && ngx_quit == 0 | ||
| && ngx_exiting == 0 | ||
| && ngx_terminate == 0 | ||
| { | ||
| ngx_event_add_timer(&mut *ev, MIN_TIMEOUT_MS); | ||
| } |
There was a problem hiding this comment.
[nitpick] The timer-setup guard logic is duplicated across multiple methods. Consider extracting this into a helper like add_timer_if_allowed(ev: &mut ngx_event_t, timeout: u64) to reduce repetition and improve readability.
Suggested change
| if (*ev).timer_set() == 0 | |
| && ngx_quit == 0 | |
| && ngx_exiting == 0 | |
| && ngx_terminate == 0 | |
| { | |
| ngx_event_add_timer(&mut *ev, MIN_TIMEOUT_MS); | |
| } | |
| add_timer_if_allowed(&mut *ev, MIN_TIMEOUT_MS); |
gabioprisan
approved these changes
Jul 1, 2025
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.
No description provided.