Skip to content

allow mpm to be note connections that are not TCP based. - #699

Open
machine-moon wants to merge 4 commits into
apache:trunkfrom
machine-moon:trunk
Open

allow mpm to be note connections that are not TCP based.#699
machine-moon wants to merge 4 commits into
apache:trunkfrom
machine-moon:trunk

Conversation

@machine-moon

@machine-moon machine-moon commented Jul 28, 2026

Copy link
Copy Markdown

2 commits:

mpm prefork and worker: c80fb0e

mpm_event: 7cbb186

@jfclere

jfclere commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Looks OK for me, could we move forward, any comments?

@machine-moon

Copy link
Copy Markdown
Author

fetched latest apache/trunk and cherry-picked my commits on top, the conflict was in the CHANGES file.

@covener

covener commented Aug 13, 2026

Copy link
Copy Markdown
Member

needs an MMN bump?

ap_run_child_stopping(pchild, !retained->mpm->is_ungraceful);
if (!retained->mpm->is_ungraceful) {
while (apr_atomic_read32(&connection_count) > 0) {
apr_sleep(apr_time_from_msec(100));

@covener covener Aug 13, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we re-purpose Timeout or GracefulShutdownTimeout here, minimally for logging?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like the following no?:

if (terminate_mode == ST_GRACEFUL) {
apr_time_t start_time = apr_time_now();
/* ap_graceful_shutdown_timeout is in seconds; 0 means wait indefinitely */
apr_time_t timeout_interval = apr_time_from_sec(ap_graceful_shutdown_timeout);

while (apr_atomic_read32(&connection_count) > 0) {
    /* Check if we exceeded GracefulShutdownTimeout (if timeout > 0) */
    if (ap_graceful_shutdown_timeout > 0 && 
       (apr_time_now() - start_time) >= timeout_interval) {
        ap_log_error(APLOG_MARK, APLOG_WARNING, 0, ap_server_conf,
                     APLOGNO(...) "Graceful shutdown timeout (%d sec) expired, "
                     "forcing exit with %u active connections",
                     ap_graceful_shutdown_timeout,
                     apr_atomic_read32(&connection_count));
        break;
    }

    /* Check if server state changed to forced terminate mid-graceful */
    if (ap_mpm_state == AP_MPMQ_STOPPING) {
        break;
    }

    apr_sleep(apr_time_from_msec(100));
}

}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never realized the default was 0, it would mean still waiting forever w/ on message if the added connections aren't removed in a timely way.

Some other ideas (no strong feelings):

  • Max of Timeout or ap_graceful_shutdown_timeout here at least for the logging aspect?
  • Maybe in the header we could reinforce what we expect of modules that add connections this way, i.e. detecting graceful termination and putting some bound on how long they can linger?

@jfclere

jfclere commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

I am afraid it does require a MMN bump
ap_mpm_note_extra_connection_added() and ap_mpm_note_extra_connection_removed() are hooks introduced by the PR.

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.

3 participants