From 603815e57425ae84e2f094a1b5f9b922f2c7a292 Mon Sep 17 00:00:00 2001 From: Joe Orton Date: Mon, 20 Jan 2020 09:09:56 +0000 Subject: [PATCH] mod_systemd: fix timeouts on reload w/ExtendedStatus off (#1590877) Resolves: rhbz#1590877 --- ...ystemd.patch => httpd-2.4.41-systemd.patch | 77 +++++++++---------- httpd.spec | 7 +- 2 files changed, 41 insertions(+), 43 deletions(-) rename httpd-2.4.33-systemd.patch => httpd-2.4.41-systemd.patch (76%) diff --git a/httpd-2.4.33-systemd.patch b/httpd-2.4.41-systemd.patch similarity index 76% rename from httpd-2.4.33-systemd.patch rename to httpd-2.4.41-systemd.patch index 7f5ee3b..5369bd9 100644 --- a/httpd-2.4.33-systemd.patch +++ b/httpd-2.4.41-systemd.patch @@ -1,5 +1,5 @@ ---- httpd-2.4.33/modules/arch/unix/config5.m4.systemd -+++ httpd-2.4.33/modules/arch/unix/config5.m4 +--- httpd-2.4.41/modules/arch/unix/config5.m4.systemd ++++ httpd-2.4.41/modules/arch/unix/config5.m4 @@ -18,6 +18,16 @@ fi ]) @@ -17,9 +17,9 @@ APR_ADDTO(INCLUDES, [-I\$(top_srcdir)/$modpath_current]) APACHE_MODPATH_FINISH ---- httpd-2.4.33/modules/arch/unix/mod_systemd.c.systemd -+++ httpd-2.4.33/modules/arch/unix/mod_systemd.c -@@ -0,0 +1,223 @@ +--- httpd-2.4.41/modules/arch/unix/mod_systemd.c.systemd ++++ httpd-2.4.41/modules/arch/unix/mod_systemd.c +@@ -0,0 +1,218 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. @@ -87,8 +87,15 @@ + return apr_psprintf(p, "%s port %u", addr, sa->port); +} + ++/* Report the service is ready in post_config, which could be during ++ * startup or after a reload. The server could still hit a fatal ++ * startup error after this point during ap_run_mpm(), so this is ++ * perhaps too early, but by post_config listen() has been called on ++ * the TCP ports so new connections will not be rejected. There will ++ * always be a possible async failure event simultaneous to the ++ * service reporting "ready", so this should be good enough. */ +static int systemd_post_config(apr_pool_t *pconf, apr_pool_t *plog, -+ apr_pool_t *ptemp, server_rec *s) ++ apr_pool_t *ptemp, server_rec *main_server) +{ + ap_listen_rec *lr; + apr_size_t plen = sizeof describe_listeners; @@ -117,25 +124,23 @@ + } + } + -+ sd_journal_print(LOG_INFO, "Server configured, listening on: %s", describe_listeners); ++ sd_notify(0, "READY=1\n" ++ "STATUS=Configuration loaded.\n"); ++ ++ sd_journal_print(LOG_INFO, "Server configured, listening on: %s", ++ describe_listeners); + + return OK; +} + +static int systemd_pre_mpm(apr_pool_t *p, ap_scoreboard_e sb_type) +{ -+ int rv; -+ + mainpid = getpid(); -+ -+ rv = sd_notifyf(0, "READY=1\n" -+ "STATUS=Started, listening on: %s\n" -+ "MAINPID=%" APR_PID_T_FMT, -+ describe_listeners, mainpid); -+ if (rv < 0) { -+ ap_log_perror(APLOG_MARK, APLOG_ERR, 0, p, APLOGNO(02395) -+ "sd_notifyf returned an error %d", rv); -+ } ++ ++ sd_notifyf(0, "READY=1\n" ++ "STATUS=Started, listening on: %s\n" ++ "MAINPID=%" APR_PID_T_FMT, ++ describe_listeners, mainpid); + + return OK; +} @@ -145,19 +150,18 @@ + ap_sload_t sload; + apr_interval_time_t up_time; + char bps[5]; -+ int rv; + + if (!ap_extended_status) { -+ /* Nothing useful to report if ExtendedStatus disabled. */ ++ /* Nothing useful to report with ExtendedStatus disabled. */ + return DECLINED; + } + + ap_get_sload(&sload); + + if (sload.access_count == 0) { -+ rv = sd_notifyf(0, "READY=1\n" -+ "STATUS=Running, listening on: %s\n", -+ describe_listeners); ++ sd_notifyf(0, "READY=1\n" ++ "STATUS=Running, listening on: %s\n", ++ describe_listeners); + } + else { + /* up_time in seconds */ @@ -167,16 +171,11 @@ + apr_strfsize((unsigned long)((float) (sload.bytes_served) + / (float) up_time), bps); + -+ rv = sd_notifyf(0, "READY=1\n" -+ "STATUS=Total requests: %lu; Idle/Busy workers %d/%d;" -+ "Requests/sec: %.3g; Bytes served/sec: %sB/sec\n", -+ sload.access_count, sload.idle, sload.busy, -+ ((float) sload.access_count) / (float) up_time, bps); -+ } -+ -+ if (rv < 0) { -+ ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, APLOGNO(02396) -+ "sd_notifyf returned an error %d", rv); ++ sd_notifyf(0, "READY=1\n" ++ "STATUS=Total requests: %lu; Idle/Busy workers %d/%d;" ++ "Requests/sec: %.3g; Bytes served/sec: %sB/sec\n", ++ sload.access_count, sload.idle, sload.busy, ++ ((float) sload.access_count) / (float) up_time, bps); + } + + /* Shutdown httpd when nothing is sent for shutdown_timer seconds. */ @@ -184,13 +183,9 @@ + /* mpm_common.c: INTERVAL_OF_WRITABLE_PROBES is 10 */ + shutdown_counter += 10; + if (shutdown_timer > 0 && shutdown_counter >= shutdown_timer) { -+ rv = sd_notifyf(0, "READY=1\n" -+ "STATUS=Stopped as result of IdleShutdown " -+ "timeout."); -+ if (rv < 0) { -+ ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, APLOGNO(02804) -+ "sd_notifyf returned an error %d", rv); -+ } ++ sd_notifyf(0, "READY=1\n" ++ "STATUS=Stopped as result of IdleShutdown " ++ "timeout."); + kill(mainpid, AP_SIG_GRACEFUL); + } + } @@ -208,7 +203,7 @@ + /* Enable ap_extended_status. */ + ap_hook_pre_config(systemd_pre_config, NULL, NULL, APR_HOOK_LAST); + /* Grab the listener config. */ -+ ap_hook_post_config(systemd_post_config, NULL, NULL, APR_HOOK_LAST); ++ ap_hook_post_config(systemd_post_config, NULL, NULL, APR_HOOK_REALLY_LAST); + /* We know the PID in this hook ... */ + ap_hook_pre_mpm(systemd_pre_mpm, NULL, NULL, APR_HOOK_LAST); + /* Used to update httpd's status line using sd_notifyf */ diff --git a/httpd.spec b/httpd.spec index a08e7df..5c59152 100644 --- a/httpd.spec +++ b/httpd.spec @@ -13,7 +13,7 @@ Summary: Apache HTTP Server Name: httpd Version: 2.4.41 -Release: 11%{?dist} +Release: 12%{?dist} URL: https://httpd.apache.org/ Source0: https://www.apache.org/dist/httpd/httpd-%{version}.tar.bz2 Source1: https://www.apache.org/dist/httpd/httpd-%{version}.tar.bz2.asc @@ -72,7 +72,7 @@ Patch23: httpd-2.4.39-export.patch Patch24: httpd-2.4.1-corelimit.patch Patch25: httpd-2.4.25-selinux.patch Patch27: httpd-2.4.2-icons.patch -Patch29: httpd-2.4.33-systemd.patch +Patch29: httpd-2.4.41-systemd.patch Patch30: httpd-2.4.4-cachehardmax.patch Patch31: httpd-2.4.33-sslmultiproxy.patch Patch34: httpd-2.4.17-socket-activation.patch @@ -753,6 +753,9 @@ exit $rv %{_rpmconfigdir}/macros.d/macros.httpd %changelog +* Mon Jan 20 2020 Joe Orton - 2.4.41-12 +- mod_systemd: fix timeouts on reload w/ExtendedStatus off (#1590877) + * Mon Jan 6 2020 Joe Orton - 2.4.41-11 - apachectl(8): update authors