You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by jk...@apache.org on 2014/08/18 09:43:43 UTC

svn commit: r1618555 - /httpd/httpd/trunk/server/mpm/prefork/prefork.c

Author: jkaluza
Date: Mon Aug 18 07:43:43 2014
New Revision: 1618555

URL: http://svn.apache.org/r1618555
Log:
prefork: Ignore SIGINT in child. This fixes race-condition in signals handling
when httpd is runnning on foreground and user hits ctrl+c. In this case, SIGINT
is sent to all children followed by SIGTERM from the main process, which
interrupts the SIGINT handler and leads to inconsistency (process freezes
or crashes).

Modified:
    httpd/httpd/trunk/server/mpm/prefork/prefork.c

Modified: httpd/httpd/trunk/server/mpm/prefork/prefork.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/prefork/prefork.c?rev=1618555&r1=1618554&r2=1618555&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/prefork/prefork.c (original)
+++ httpd/httpd/trunk/server/mpm/prefork/prefork.c Mon Aug 18 07:43:43 2014
@@ -222,6 +222,9 @@ static void clean_child_exit(int code)
 {
     mpm_state = AP_MPMQ_STOPPING;
 
+    apr_signal(SIGHUP, SIG_IGN);
+    apr_signal(SIGTERM, SIG_IGN);
+
     if (pchild) {
         apr_pool_destroy(pchild);
     }
@@ -817,6 +820,13 @@ static int make_child(server_rec *s, int
          */
         apr_signal(SIGHUP, just_die);
         apr_signal(SIGTERM, just_die);
+        /* Ignore SIGINT in child. This fixes race-condition in signals
+         * handling when httpd is runnning on foreground and user hits ctrl+c.
+         * In this case, SIGINT is sent to all children followed by SIGTERM
+         * from the main process, which interrupts the SIGINT handler and
+         * leads to inconsistency.
+         */
+        apr_signal(SIGINT, SIG_IGN);
         /* The child process just closes listeners on AP_SIG_GRACEFUL.
          * The pod is used for signalling the graceful restart.
          */



Re: svn commit: r1618555 - /httpd/httpd/trunk/server/mpm/prefork/prefork.c

Posted by Jan Kaluža <jk...@redhat.com>.
On 08/18/2014 04:31 PM, Jan Kaluža wrote:
> On 08/18/2014 02:20 PM, Ruediger Pluem wrote:
>>
>>
>> jkaluza@apache.org wrote:
>>> Author: jkaluza
>>> Date: Mon Aug 18 07:43:43 2014
>>> New Revision: 1618555
>>>
>>> URL: http://svn.apache.org/r1618555
>>> Log:
>>> prefork: Ignore SIGINT in child. This fixes race-condition in signals
>>> handling
>>> when httpd is runnning on foreground and user hits ctrl+c. In this
>>> case, SIGINT
>>> is sent to all children followed by SIGTERM from the main process, which
>>> interrupts the SIGINT handler and leads to inconsistency (process
>>> freezes
>>> or crashes).
>>>
>>> Modified:
>>>      httpd/httpd/trunk/server/mpm/prefork/prefork.c
>>>
>>
>> Don't we need to do this for the other MPM's as well?
>
> I haven't tried to reproduce it with different MPMs, but it looks like
> good idea. The code looks very similar when it comes to signal handling,
> so the same problem can be there too. I will try to reproduce this bug
> and commit fix also for other MPMs eventually.

I was not able to reproduce the bug with event or worker MPM. That does 
not mean the problem is not there, but I don't want to fix it blindly 
without seeing the actual bug.

Jan Kaluza

> Jan Kaluza
>
>> Regards
>>
>> Rüdiger
>>
>


Re: svn commit: r1618555 - /httpd/httpd/trunk/server/mpm/prefork/prefork.c

Posted by Jan Kaluža <jk...@redhat.com>.
On 08/18/2014 02:20 PM, Ruediger Pluem wrote:
>
>
> jkaluza@apache.org wrote:
>> Author: jkaluza
>> Date: Mon Aug 18 07:43:43 2014
>> New Revision: 1618555
>>
>> URL: http://svn.apache.org/r1618555
>> Log:
>> prefork: Ignore SIGINT in child. This fixes race-condition in signals handling
>> when httpd is runnning on foreground and user hits ctrl+c. In this case, SIGINT
>> is sent to all children followed by SIGTERM from the main process, which
>> interrupts the SIGINT handler and leads to inconsistency (process freezes
>> or crashes).
>>
>> Modified:
>>      httpd/httpd/trunk/server/mpm/prefork/prefork.c
>>
>
> Don't we need to do this for the other MPM's as well?

I haven't tried to reproduce it with different MPMs, but it looks like 
good idea. The code looks very similar when it comes to signal handling, 
so the same problem can be there too. I will try to reproduce this bug 
and commit fix also for other MPMs eventually.

Jan Kaluza

> Regards
>
> Rüdiger
>


Re: svn commit: r1618555 - /httpd/httpd/trunk/server/mpm/prefork/prefork.c

Posted by Ruediger Pluem <rp...@apache.org>.

jkaluza@apache.org wrote:
> Author: jkaluza
> Date: Mon Aug 18 07:43:43 2014
> New Revision: 1618555
> 
> URL: http://svn.apache.org/r1618555
> Log:
> prefork: Ignore SIGINT in child. This fixes race-condition in signals handling
> when httpd is runnning on foreground and user hits ctrl+c. In this case, SIGINT
> is sent to all children followed by SIGTERM from the main process, which
> interrupts the SIGINT handler and leads to inconsistency (process freezes
> or crashes).
> 
> Modified:
>     httpd/httpd/trunk/server/mpm/prefork/prefork.c
> 

Don't we need to do this for the other MPM's as well?

Regards

Rüdiger