Skip to content

Commit 2bd142f

Browse files
committed
Add --enable-sigusr2 to use SIGUSR2 rather than SIGWINCH for graceful
stop, which requires APR 1.7+. * configure.in: Add --enable-sigusr2; define AP_SIG_GRACEFUL_STOP* in ap_config.h. * include/mpm_common.h: Define AP_SIG_GRACEFUL_STOP* conditionally. * server/mpm/prefork/prefork.c (child_main): Don't mention SIGWINCH. PR: 50669
1 parent 9d74906 commit 2bd142f

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

configure.in

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,24 @@ if test "$apache_need_shared" = "yes"; then
830830
shared_build="shared-build"
831831
fi
832832

833+
ap_graceful_sig=WINCH
834+
AC_ARG_ENABLE(sigusr2,
835+
APACHE_HELP_STRING(--enable-sigusr2,Use SIGUSR2 for graceful stop),
836+
[
837+
case $APR_VERSION in
838+
0.*|1.[[0-6]].*) AC_MSG_ERROR([APR 1.7 or later is required to use SIGUSR2]) ;;
839+
esac
840+
ap_graceful_sig=USR2
841+
])
842+
AC_MSG_NOTICE([using signal SIG$ap_graceful_sig for graceful stop])
843+
844+
AC_DEFINE_UNQUOTED([AP_SIG_GRACEFUL_STOP], [SIG$ap_graceful_sig],
845+
[Signal to use for graceful stop])
846+
AC_DEFINE_UNQUOTED([AP_SIG_GRACEFUL_STOP_STRING],
847+
["SIG$ap_graceful_sig"], [Signal name in use for graceful stop])
848+
AC_DEFINE_UNQUOTED([AP_SIG_GRACEFUL_STOP_SHORT],
849+
[$ap_graceful_sig], [Short signal name in use for graceful stop])
850+
833851
dnl enable_so tells us if *any* modules can be built as DSOs
834852

835853
if test "$enable_so" = "yes" -o "$enable_so" = "static"; then

include/mpm_common.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,20 @@ extern "C" {
8080
/* Signal used to gracefully restart (as a quoted string) */
8181
#define AP_SIG_GRACEFUL_STRING "SIGUSR1"
8282

83+
#ifndef AP_SIG_GRACEFUL_STOP
8384
/* Signal used to gracefully stop */
8485
#define AP_SIG_GRACEFUL_STOP SIGWINCH
86+
#endif
8587

88+
#ifndef AP_SIG_GRACEFUL_STOP_SHORT
8689
/* Signal used to gracefully stop (without SIG prefix) */
8790
#define AP_SIG_GRACEFUL_STOP_SHORT WINCH
91+
#endif
8892

93+
#ifndef AP_SIG_GRACEFUL_STOP_STRING
8994
/* Signal used to gracefully stop (as a quoted string) */
9095
#define AP_SIG_GRACEFUL_STOP_STRING "SIGWINCH"
96+
#endif
9197

9298
/**
9399
* Callback function used for ap_reclaim_child_processes() and

server/mpm/prefork/prefork.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -541,10 +541,10 @@ static void child_main(int child_num_arg, int child_bucket)
541541

542542
status = apr_pollset_add(pollset, pfd);
543543
if (status != APR_SUCCESS) {
544-
/* If the child processed a SIGWINCH before setting up the
545-
* pollset, this error path is expected and harmless,
546-
* since the listener fd was already closed; so don't
547-
* pollute the logs in that case. */
544+
/* If the child processed a graceful-stop signal before
545+
* setting up the pollset, this error path is expected and
546+
* harmless, since the listener fd was already closed; so
547+
* don't pollute the logs in that case. */
548548
if (!die_now) {
549549
ap_log_error(APLOG_MARK, APLOG_EMERG, status, ap_server_conf, APLOGNO(00157)
550550
"Couldn't add listener to pollset; check system or user limits");

0 commit comments

Comments
 (0)