From cvs-return-68443-archive-asf-public=cust-asf.ponee.io@httpd.apache.org Fri Jun 4 13:21:30 2021 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mxout1-ec2-va.apache.org (mxout1-ec2-va.apache.org [3.227.148.255]) by mx-eu-01.ponee.io (Postfix) with ESMTPS id B300B18066B for ; Fri, 4 Jun 2021 15:21:30 +0200 (CEST) Received: from mail.apache.org (mailroute1-lw-us.apache.org [207.244.88.153]) by mxout1-ec2-va.apache.org (ASF Mail Server at mxout1-ec2-va.apache.org) with SMTP id D96E64045E for ; Fri, 4 Jun 2021 13:21:29 +0000 (UTC) Received: (qmail 22675 invoked by uid 500); 4 Jun 2021 13:21:29 -0000 Mailing-List: contact cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list cvs@httpd.apache.org Received: (qmail 22666 invoked by uid 99); 4 Jun 2021 13:21:29 -0000 Received: from Unknown (HELO svn01-us-east.apache.org) (13.90.137.153) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Jun 2021 13:21:29 +0000 Received: from svn01-us-east.apache.org (svn01-us-east.apache.org [127.0.0.1]) by svn01-us-east.apache.org (ASF Mail Server at svn01-us-east.apache.org) with ESMTP id 18C7217DD86 for ; Fri, 4 Jun 2021 13:21:29 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1890465 - in /httpd/httpd/trunk: changes-entries/prefork_child_init_sigmask.txt docs/log-message-tags/next-number server/mpm/prefork/prefork.c Date: Fri, 04 Jun 2021 13:21:29 -0000 To: cvs@httpd.apache.org From: ylavic@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20210604132129.18C7217DD86@svn01-us-east.apache.org> Author: ylavic Date: Fri Jun 4 13:21:28 2021 New Revision: 1890465 URL: http://svn.apache.org/viewvc?rev=1890465&view=rev Log: mpm_prefork: mask signals during ap_run_child_init(). This prevents threads potentially created from the child_init hooks (e.g. mod_watchdog workers) to catch signals needed by the MPM, like here: https://travis-ci.com/github/apache/httpd/jobs/510821148#L5356. Added: httpd/httpd/trunk/changes-entries/prefork_child_init_sigmask.txt Modified: httpd/httpd/trunk/docs/log-message-tags/next-number httpd/httpd/trunk/server/mpm/prefork/prefork.c Added: httpd/httpd/trunk/changes-entries/prefork_child_init_sigmask.txt URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/changes-entries/prefork_child_init_sigmask.txt?rev=1890465&view=auto ============================================================================== --- httpd/httpd/trunk/changes-entries/prefork_child_init_sigmask.txt (added) +++ httpd/httpd/trunk/changes-entries/prefork_child_init_sigmask.txt Fri Jun 4 13:21:28 2021 @@ -0,0 +1,3 @@ + *) mpm_prefork: Block signals for child_init hooks to prevent potential + threads created from there to catch MPM's signals. + [Ruediger Pluem, Yann Ylavic] Modified: httpd/httpd/trunk/docs/log-message-tags/next-number URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/log-message-tags/next-number?rev=1890465&r1=1890464&r2=1890465&view=diff ============================================================================== --- httpd/httpd/trunk/docs/log-message-tags/next-number (original) +++ httpd/httpd/trunk/docs/log-message-tags/next-number Fri Jun 4 13:21:28 2021 @@ -1 +1 @@ -10271 +10272 Modified: httpd/httpd/trunk/server/mpm/prefork/prefork.c URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/prefork/prefork.c?rev=1890465&r1=1890464&r2=1890465&view=diff ============================================================================== --- httpd/httpd/trunk/server/mpm/prefork/prefork.c (original) +++ httpd/httpd/trunk/server/mpm/prefork/prefork.c Fri Jun 4 13:21:28 2021 @@ -382,11 +382,23 @@ static void stop_listening(int sig) static int requests_this_child; static int num_listensocks = 0; +#if APR_HAS_THREADS +static void child_sigmask(sigset_t *new_mask, sigset_t *old_mask) +{ +#if defined(SIGPROCMASK_SETS_THREAD_MASK) + sigprocmask(SIG_SETMASK, new_mask, old_mask); +#else + pthread_sigmask(SIG_SETMASK, new_mask, old_mask); +#endif +} +#endif + static void child_main(int child_num_arg, int child_bucket) { #if APR_HAS_THREADS apr_thread_t *thd = NULL; apr_os_thread_t osthd; + sigset_t sig_mask; #endif apr_pool_t *ptrans; apr_allocator_t *allocator; @@ -452,8 +464,31 @@ static void child_main(int child_num_arg clean_child_exit(APEXIT_CHILDFATAL); } +#if APR_HAS_THREADS + /* Save the signal mask and block all the signals from being received by + * threads potentially created in child_init() hooks (e.g. mod_watchdog). + */ + child_sigmask(NULL, &sig_mask); + { + apr_status_t rv; + rv = apr_setup_signal_thread(); + if (rv != APR_SUCCESS) { + ap_log_error(APLOG_MARK, APLOG_EMERG, rv, ap_server_conf, APLOGNO(10271) + "Couldn't initialize signal thread"); + clean_child_exit(APEXIT_CHILDFATAL); + } + } +#endif /* APR_HAS_THREADS */ + ap_run_child_init(pchild, ap_server_conf); +#if APR_HAS_THREADS + /* Restore the original signal mask for this main thread, the only one + * that should possibly get interrupted by signals. + */ + child_sigmask(&sig_mask, NULL); +#endif + ap_create_sb_handle(&sbh, pchild, my_child_num, 0); (void) ap_update_child_status(sbh, SERVER_READY, (request_rec *) NULL);