From 0fdc382d61768fa42a68beb8508eac7f3681a20e Mon Sep 17 00:00:00 2001 From: Joe Orton Date: Wed, 19 Sep 2012 16:43:29 +0100 Subject: [PATCH] fix some error log spam with graceful-stop (r1387633) - minor mod_systemd tweaks --- httpd-2.4.2-r1387633.patch | 23 ++++++++ httpd-2.4.3-mod_systemd.patch | 104 +++++++++++++++------------------- httpd.spec | 8 ++- 3 files changed, 76 insertions(+), 59 deletions(-) create mode 100644 httpd-2.4.2-r1387633.patch diff --git a/httpd-2.4.2-r1387633.patch b/httpd-2.4.2-r1387633.patch new file mode 100644 index 0000000..3fc0143 --- /dev/null +++ b/httpd-2.4.2-r1387633.patch @@ -0,0 +1,23 @@ +# ./pullrev.sh 1387633 + +http://svn.apache.org/viewvc?view=revision&revision=1387633 + +--- httpd-2.4.2/server/mpm/prefork/prefork.c ++++ httpd-2.4.2/server/mpm/prefork/prefork.c +@@ -564,8 +564,14 @@ + + status = apr_pollset_add(pollset, &pfd); + if (status != APR_SUCCESS) { +- ap_log_error(APLOG_MARK, APLOG_EMERG, status, ap_server_conf, APLOGNO(00157) +- "Couldn't add listener to pollset; check system or user limits"); ++ /* If the child processed a SIGWINCH before setting up the ++ * pollset, this error path is expected and harmless, ++ * since the listener fd was already closed; so don't ++ * pollute the logs in that case. */ ++ if (!die_now) { ++ ap_log_error(APLOG_MARK, APLOG_EMERG, status, ap_server_conf, APLOGNO(00157) ++ "Couldn't add listener to pollset; check system or user limits"); ++ } + clean_child_exit(APEXIT_CHILDSICK); + } + diff --git a/httpd-2.4.3-mod_systemd.patch b/httpd-2.4.3-mod_systemd.patch index 3b279b6..701234e 100644 --- a/httpd-2.4.3-mod_systemd.patch +++ b/httpd-2.4.3-mod_systemd.patch @@ -1,9 +1,28 @@ -diff --git a/modules/arch/unix/mod_systemd.c b/modules/arch/unix/mod_systemd.c -new file mode 100644 -index 0000000..40dca79 ---- /dev/null -+++ b/modules/arch/unix/mod_systemd.c -@@ -0,0 +1,145 @@ +--- httpd-2.4.3/modules/arch/unix/config5.m4.systemd ++++ httpd-2.4.3/modules/arch/unix/config5.m4 +@@ -18,6 +18,19 @@ APACHE_MODULE(privileges, Per-virtualhos + fi + ]) + ++ ++APACHE_MODULE(systemd, Systemd support, , , $unixd_mods_enabled, [ ++ AC_CHECK_LIB(systemd-daemon, sd_notify, SYSTEMD_LIBS="-lsystemd-daemon") ++ AC_CHECK_HEADERS(systemd/sd-daemon.h, [ap_HAVE_SD_DAEMON_H="yes"], [ap_HAVE_SD_DAEMON_H="no"]) ++ if test $ap_HAVE_SD_DAEMON_H = "no" || test -z "${LUA_LIBS}"; then ++ AC_MSG_WARN([Your system does not support systemd.]) ++ enable_systemd="no" ++ else ++ APR_ADDTO(MOD_SYSTEMD_LDADD, [$SYSTEMD_LIBS]) ++ enable_systemd="yes" ++ fi ++]) ++ + APR_ADDTO(INCLUDES, [-I\$(top_srcdir)/$modpath_current]) + + APACHE_MODPATH_FINISH +--- httpd-2.4.3/modules/arch/unix/mod_systemd.c.systemd ++++ httpd-2.4.3/modules/arch/unix/mod_systemd.c +@@ -0,0 +1,138 @@ +/* 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. @@ -47,8 +66,7 @@ index 0000000..40dca79 +static unsigned long last_update_access; +static unsigned long last_update_kbytes; + -+static int systemd_post_config(apr_pool_t *p, apr_pool_t *plog, -+ apr_pool_t *ptemp, server_rec *s) ++static int systemd_pre_mpm(apr_pool_t *p, ap_scoreboard_e sb_type) +{ + int rv; + last_update_time = time(0); @@ -61,33 +79,29 @@ index 0000000..40dca79 + threads_per_child = 1; + ap_mpm_query(AP_MPMQ_MAX_DAEMONS, &max_servers); + -+ /* For every MPM, there is already the main process ready in -+ * AP_SQ_MS_CREATE_CONFIG state. */ -+ if (pid == 0 && ap_state_query(AP_SQ_MAIN_STATE) == AP_SQ_MS_CREATE_CONFIG) -+ { -+ pid = getpid(); -+ -+ rv = sd_notifyf(0, "READY=1\n" -+ "STATUS=Processing requests...\n" -+ "MAINPID=%lu", -+ (unsigned long) pid); -+ if (rv < 0) -+ { -+ ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, APLOGNO(00000) -+ "sd_notifyf returned an error %d", rv); -+ } ++ pid = getpid(); ++ ++ rv = sd_notifyf(0, "READY=1\n" ++ "STATUS=Processing requests...\n" ++ "MAINPID=%lu", ++ (unsigned long) pid); ++ if (rv < 0) { ++ ap_log_perror(APLOG_MARK, APLOG_ERR, 0, p, ++ "sd_notifyf returned an error %d", rv); + } ++ + return OK; +} + -+static int systemd_monitor(apr_pool_t *p, server_rec *s) { ++static int systemd_monitor(apr_pool_t *p, server_rec *s) ++{ + int i, j, res, rv; + process_score *ps_record; + worker_score *ws_record; + unsigned long access = 0; + unsigned long bytes = 0; + unsigned long kbytes = 0; -+ ++ char bps[5]; + time_t now = time(0); + time_t elapsed = now - last_update_time; + @@ -110,18 +124,16 @@ index 0000000..40dca79 + } + } + -+ char bps[5]; + apr_strfsize((unsigned long)(KBYTE *(float) (kbytes - last_update_kbytes) -+ / (float) elapsed), bps); ++ / (float) elapsed), bps); + + rv = sd_notifyf(0, "READY=1\n" -+ "STATUS=Total requests: %lu; Current requests/sec: %.3g; " -+ "Current traffic: %sB/sec\n", access, -+ ((float)access - last_update_access) / (float) elapsed, bps); -+ if (rv < 0) -+ { ++ "STATUS=Total requests: %lu; Current requests/sec: %.3g; " ++ "Current traffic: %sB/sec\n", access, ++ ((float)access - last_update_access) / (float) elapsed, bps); ++ if (rv < 0) { + ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, APLOGNO(00000) -+ "sd_notifyf returned an error %d", rv); ++ "sd_notifyf returned an error %d", rv); + } + + last_update_access = access; @@ -134,7 +146,7 @@ index 0000000..40dca79 +static void systemd_register_hooks(apr_pool_t *p) +{ + /* We know the PID in this hook ... */ -+ ap_hook_post_config(systemd_post_config, NULL, NULL, APR_HOOK_LAST); ++ ap_hook_pre_mpm(systemd_pre_mpm, NULL, NULL, APR_HOOK_LAST); + /* Used to update httpd's status line using sd_notifyf */ + ap_hook_monitor(systemd_monitor, NULL, NULL, APR_HOOK_MIDDLE); +} @@ -149,27 +161,3 @@ index 0000000..40dca79 + NULL, + systemd_register_hooks, +}; -diff --git a/modules/arch/unix/config5.m4 b/modules/arch/unix/config5.m4 -index 77027a8..4fd9799 100644 ---- a/modules/arch/unix/config5.m4 -+++ b/modules/arch/unix/config5.m4 -@@ -18,6 +18,19 @@ APACHE_MODULE(privileges, Per-virtualhost Unix UserIDs and enhanced security for - fi - ]) - -+ -+APACHE_MODULE(systemd, Systemd support, , , $unixd_mods_enabled, [ -+ AC_CHECK_LIB(systemd-daemon, sd_notify, SYSTEMD_LIBS="-lsystemd-daemon") -+ AC_CHECK_HEADERS(systemd/sd-daemon.h, [ap_HAVE_SD_DAEMON_H="yes"], [ap_HAVE_SD_DAEMON_H="no"]) -+ if test $ap_HAVE_SD_DAEMON_H = "no" || test -z "${LUA_LIBS}"; then -+ AC_MSG_WARN([Your system does not support systemd.]) -+ enable_systemd="no" -+ else -+ APR_ADDTO(MOD_SYSTEMD_LDADD, [$SYSTEMD_LIBS]) -+ enable_systemd="yes" -+ fi -+]) -+ - APR_ADDTO(INCLUDES, [-I\$(top_srcdir)/$modpath_current]) - - APACHE_MODPATH_FINISH diff --git a/httpd.spec b/httpd.spec index e9aaadf..4ebd149 100644 --- a/httpd.spec +++ b/httpd.spec @@ -8,7 +8,7 @@ Summary: Apache HTTP Server Name: httpd Version: 2.4.3 -Release: 4%{?dist} +Release: 5%{?dist} URL: http://httpd.apache.org/ Source0: http://www.apache.org/dist/httpd/httpd-%{version}.tar.bz2 Source1: index.html @@ -52,6 +52,7 @@ Patch28: httpd-2.4.2-r1332643+.patch Patch29: httpd-2.4.3-mod_systemd.patch # Bug fixes Patch50: httpd-2.4.2-r1374214+.patch +Patch51: httpd-2.4.2-r1387633.patch License: ASL 2.0 Group: System Environment/Daemons BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root @@ -163,6 +164,7 @@ authentication to the Apache HTTP Server. %patch29 -p1 -b .systemd %patch50 -p1 -b .r1374214+ +%patch51 -p1 -b .r1387633 # Patch in vendor/release string sed "s/@RELEASE@/%{vstring}/" < %{PATCH20} | patch --fuzz=%{_default_patch_fuzz} -p1 @@ -578,6 +580,10 @@ rm -rf $RPM_BUILD_ROOT %{_sysconfdir}/rpm/macros.httpd %changelog +* Wed Sep 19 2012 Joe Orton - 2.4.3-5 +- fix some error log spam with graceful-stop (r1387633) +- minor mod_systemd tweaks + * Thu Sep 13 2012 Joe Orton - 2.4.3-4 - use IncludeOptional for conf.d/*.conf inclusion