-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[BACKPORT] allow mpm to be note connections that are not TCP based. #709
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
machine-moon
wants to merge
8
commits into
apache:2.4.x
Choose a base branch
from
machine-moon:2.4.69-143
base: 2.4.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6eb5b60
mpm_prefork: give clean_child_exit() a from_signal variant
machine-moon d3b53fc
mpm_event update
machine-moon 36bb75d
mpm prefork and worker update
machine-moon 5cc8e15
mpm_winnt update
machine-moon 55210d4
update CHANGES
machine-moon 5e261f5
bump mmn
machine-moon 3b3ab0b
bounded graceful shutdown for extra connections
machine-moon 9786891
consistency sweep
machine-moon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 10623 | ||
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ | |
| #include "apr_portable.h" | ||
| #include "apr_strings.h" | ||
| #include "apr_thread_proc.h" | ||
| #include "apr_atomic.h" | ||
| #include "apr_signal.h" | ||
|
|
||
| #define APR_WANT_STDIO | ||
|
|
@@ -88,6 +89,7 @@ | |
|
|
||
| /* config globals */ | ||
|
|
||
| static apr_uint32_t extra_connection_count = 0; /* Number of open connections that the MPM does not own */ | ||
| static int ap_daemons_to_start=0; | ||
| static int ap_daemons_min_free=0; | ||
| static int ap_daemons_max_free=0; | ||
|
|
@@ -214,20 +216,60 @@ static void prefork_note_child_started(int slot, pid_t pid) | |
| ap_run_child_status(ap_server_conf, pid, gen, slot, MPM_CHILD_STARTED); | ||
| } | ||
|
|
||
| static void ap_mpm_note_extra_connection_added(void) | ||
| { | ||
| apr_atomic_inc32(&extra_connection_count); | ||
| } | ||
|
|
||
| static void ap_mpm_note_extra_connection_removed(void) | ||
| { | ||
| apr_atomic_dec32(&extra_connection_count); | ||
| } | ||
|
|
||
| static void wait_for_extra_connections(void) | ||
| { | ||
| apr_uint32_t count = apr_atomic_read32(&extra_connection_count); | ||
| apr_time_t graceful, timeout, deadline; | ||
|
|
||
| if (count == 0) { | ||
| return; | ||
| } | ||
|
|
||
| graceful = apr_time_from_sec(ap_graceful_shutdown_timeout); | ||
| timeout = (graceful > ap_server_conf->timeout) ? graceful : ap_server_conf->timeout; | ||
| deadline = apr_time_now() + timeout; | ||
|
|
||
| do { | ||
| apr_sleep(apr_time_from_msec(100)); | ||
| count = apr_atomic_read32(&extra_connection_count); | ||
| } while (count > 0 && apr_time_now() < deadline); | ||
|
|
||
| if (count > 0) { | ||
| ap_log_error(APLOG_MARK, APLOG_WARNING, 0, ap_server_conf, | ||
| APLOGNO(10620) | ||
| "Child: %u connection(s) noted by modules did not " | ||
| "finish within %" APR_TIME_T_FMT " seconds, " | ||
| "exiting anyway", | ||
| count, apr_time_sec(timeout)); | ||
| } | ||
| } | ||
|
|
||
| /* a clean exit from a child with proper cleanup */ | ||
| static void clean_child_exit(int code) __attribute__ ((noreturn)); | ||
| static void clean_child_exit(int code) | ||
| static void clean_child_exit_ex(int code, int from_signal) __attribute__ ((noreturn)); | ||
| static void clean_child_exit_ex(int code, int from_signal) | ||
| { | ||
| retained->mpm->mpm_state = AP_MPMQ_STOPPING; | ||
|
|
||
| apr_signal(SIGHUP, SIG_IGN); | ||
| apr_signal(SIGTERM, SIG_IGN); | ||
|
|
||
| if (code == 0) { | ||
| ap_run_child_stopping(pchild, 0); | ||
| } | ||
|
|
||
| if (pchild) { | ||
| if (!code && !from_signal) { | ||
| ap_run_child_stopping(pchild, !retained->mpm->is_ungraceful); | ||
| if (!retained->mpm->is_ungraceful) { | ||
| wait_for_extra_connections(); | ||
| } | ||
| } | ||
| apr_pool_destroy(pchild); | ||
| } | ||
|
|
||
|
|
@@ -240,6 +282,12 @@ static void clean_child_exit(int code) | |
| exit(code); | ||
| } | ||
|
|
||
| static void clean_child_exit(int code) __attribute__ ((noreturn)); | ||
| static void clean_child_exit(int code) | ||
| { | ||
| clean_child_exit_ex(code, 0); | ||
| } | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this change here was the only conflict |
||
|
|
||
| static apr_status_t accept_mutex_on(void) | ||
| { | ||
| apr_status_t rv = apr_proc_mutex_lock(my_bucket->mutex); | ||
|
|
@@ -356,7 +404,7 @@ static const char *prefork_get_name(void) | |
|
|
||
| static void just_die(int sig) | ||
| { | ||
| clean_child_exit(0); | ||
| clean_child_exit_ex(0, 1); | ||
| } | ||
|
|
||
| /* volatile because it's updated from a signal handler */ | ||
|
|
@@ -1286,6 +1334,9 @@ static int prefork_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp | |
| apr_status_t rv; | ||
| const char *userdata_key = "mpm_prefork_module"; | ||
|
|
||
| APR_REGISTER_OPTIONAL_FN(ap_mpm_note_extra_connection_added); | ||
| APR_REGISTER_OPTIONAL_FN(ap_mpm_note_extra_connection_removed); | ||
|
|
||
| debug = ap_exists_config_define("DEBUG"); | ||
|
|
||
| if (debug) { | ||
|
|
||
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this file didn't exist, was it suppose to?