You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Tianwei <ti...@gmail.com> on 2009/12/08 08:12:52 UTC

signal handler questions

Hi, all,
   I am doing a PMU(performance monitor unit) profiling work on apache now.
As the first step, I need to find a way to enable and disable the profiling.
I configure the apache as --with-mpm=worker, by my default configuration, it
will start 3 child processes(27threads for each process, 25 worker threads,
1 listen threads, 1 main server threads). Now I put my start function at the
entry of "child_main" in mpm/worker/worker.c.  Then during serving the
request, my code will do a self-monitoring style according to the PMU
samples. However, I do not know where to put my stop function code. The
following is my current way:
  1. I may use "sudo ./bin/apachctl -k stop" to stop the httpd
  2. normally the "stop" will be caught by the parent process, then it will
continue to sent "KILL" to child processes
  3. then for each child process, it will catch the signal from parent
process and continue to kill all its threads.
I want to put  my "stop" function at the start of step 3 where each child
process receive the signals from parent process.

I search the documents and debug the code a lot, but still can not
understand the signal-handler mechanism in httpd. Can anyone kindly point me
to the right document or code place where I can insert my stop function?

Thanks very much.

Tianwei

-- 
Sheng, Tianwei
Inst. of High Performance Computing
Dept. of Computer Sci. & Tech.
Tsinghua Univ.

Re: signal handler questions

Posted by Tianwei <ti...@gmail.com>.
On Wed, Dec 9, 2009 at 12:22 AM, Tom Evans <te...@googlemail.com> wrote:

> On Tue, Dec 8, 2009 at 2:57 PM, Tianwei <ti...@gmail.com> wrote:
> > Hi, all,
> >    I met some SIGHUP problem for my httpd-2.2.14 version. To verify this
> > problem, I use a clean 2.2.14 version, and configure it with:
> >   CFLAGS="-O0 -g" ./configure --prefix=/home/tianwei/apache/install/
> > --with-mpm=worker
> > after installing,
> > in gdb:
> > (gdb) file bin/httpd
> > Reading symbols from /home/tianwei/apache/install/bin/httpd...done.
> > (gdb) r -X -k start
> > then use ab to test it:
> > tianwei@tianwei:~/apache/install$ ./bin/ab -n 10000 http://localhost/
> > but after this testing, I receive the following error in gdb:
> > Program received signal SIGHUP, Hangup.
>
> This is expected behaviour.
>
> The default configuration of apache has "MaxRequestsPerChild 10000".
> You start apache with only one child (-X) and then issue 10,000
> requests. Apache then restarts the child.
>
> Cheers
>
> Hi, Tom,
   Got it, thanks very much.

Tianwei

> Tom
>



-- 
Sheng, Tianwei
Inst. of High Performance Computing
Dept. of Computer Sci. & Tech.
Tsinghua Univ.

Re: signal handler questions

Posted by Tom Evans <te...@googlemail.com>.
On Tue, Dec 8, 2009 at 2:57 PM, Tianwei <ti...@gmail.com> wrote:
> Hi, all,
>    I met some SIGHUP problem for my httpd-2.2.14 version. To verify this
> problem, I use a clean 2.2.14 version, and configure it with:
>   CFLAGS="-O0 -g" ./configure --prefix=/home/tianwei/apache/install/
> --with-mpm=worker
> after installing,
> in gdb:
> (gdb) file bin/httpd
> Reading symbols from /home/tianwei/apache/install/bin/httpd...done.
> (gdb) r -X -k start
> then use ab to test it:
> tianwei@tianwei:~/apache/install$ ./bin/ab -n 10000 http://localhost/
> but after this testing, I receive the following error in gdb:
> Program received signal SIGHUP, Hangup.

This is expected behaviour.

The default configuration of apache has "MaxRequestsPerChild 10000".
You start apache with only one child (-X) and then issue 10,000
requests. Apache then restarts the child.

Cheers

Tom

Re: signal handler questions

Posted by Tianwei <ti...@gmail.com>.
Hi, all,
   I met some SIGHUP problem for my httpd-2.2.14 version. To verify this
problem, I use a clean 2.2.14 version, and configure it with:
  CFLAGS="-O0 -g" ./configure --prefix=/home/tianwei/apache/install/
--with-mpm=worker

after installing,
in gdb:
(gdb) file bin/httpd
Reading symbols from /home/tianwei/apache/install/bin/httpd...done.
(gdb) r -X -k start

then use ab to test it:
tianwei@tianwei:~/apache/install$ ./bin/ab -n 10000 http://localhost/

but after this testing, I receive the following error in gdb:
Program received signal SIGHUP, Hangup.
[Switching to Thread 0x7f0d8c9f7950 (LWP 3869)]
0x00007f0d9b2071f6 in pthread_kill () from /lib/libpthread.so.0

and the backtrace is:
* 28 Thread 0x7f0d8c9f7950 (LWP 3869)  0x00007f0d9b2071f6 in pthread_kill ()
from /lib/libpthread.so.0
  27 Thread 0x7f0d8d248950 (LWP 3868)  0x00007f0d9b2062e9 in
pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
  26 Thread 0x7f0d8da99950 (LWP 3867)  0x00007f0d9b2062e9 in
pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
  25 Thread 0x7f0d8e2ea950 (LWP 3866)  0x0000000000403c0e in ap_getparents
(name=0x17fde20 "/") at util.c:486
  24 Thread 0x7f0d8eb3b950 (LWP 3865)  0x00007f0d9b2062e9 in
pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
  23 Thread 0x7f0d8f38c950 (LWP 3864)  0x00007f0d9b2062e9 in
pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
  22 Thread 0x7f0d8fbdd950 (LWP 3863)  0x00007f0d9b2062e9 in
pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
  21 Thread 0x7f0d9042e950 (LWP 3862)  0x00007f0d9b2062e9 in
pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
  20 Thread 0x7f0d90c7f950 (LWP 3861)  0x00007f0d9b2062e9 in
pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
  19 Thread 0x7f0d914d0950 (LWP 3860)  0x00007f0d9b2062e9 in
pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
  18 Thread 0x7f0d91d21950 (LWP 3859)  0x00007f0d9b2062e9 in
pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
  17 Thread 0x7f0d92572950 (LWP 3858)  0x00007f0d9b2062e9 in
pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
  16 Thread 0x7f0d92dc3950 (LWP 3857)  0x00007f0d9b2062e9 in
pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
  15 Thread 0x7f0d93614950 (LWP 3856)  0x00007f0d9b2062e9 in
pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
  14 Thread 0x7f0d93e65950 (LWP 3855)  0x00007f0d9b2062e9 in
pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
  13 Thread 0x7f0d946b6950 (LWP 3854)  0x00007f0d9b2062e9 in
pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
  12 Thread 0x7f0d94f07950 (LWP 3853)  0x00007f0d9b2062e9 in
pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
  11 Thread 0x7f0d95758950 (LWP 3852)  0x00007f0d9b2062e9 in
pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
  10 Thread 0x7f0d95fa9950 (LWP 3851)  0x00007f0d9b2062e9 in
pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
  9 Thread 0x7f0d967fa950 (LWP 3850)  0x00007f0d9b2062e9 in
pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
  8 Thread 0x7f0d9704b950 (LWP 3849)  0x00007f0d9b2062e9 in
pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
  7 Thread 0x7f0d9789c950 (LWP 3848)  0x00007f0d9b2062e9 in
pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
  6 Thread 0x7f0d980ed950 (LWP 3847)  0x00007f0d9b2062e9 in
pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
  5 Thread 0x7f0d9893e950 (LWP 3846)  0x00007f0d9b2062e9 in
pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
  4 Thread 0x7f0d9918f950 (LWP 3845)  0x00007f0d9b2062e9 in
pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
  3 Thread 0x7f0d999e0950 (LWP 3844)  0x00007f0d9b2062e9 in
pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
  1 Thread 0x7f0d9beab6f0 (LWP 3839)  0x00007f0d9b209e0b in sigwait () from
/lib/libpthread.so.0

my OS and CPU is:
root@tianwei:~# uname -a
Linux tianwei 2.6.28-15-generic #52-Ubuntu SMP Wed Sep 9 10:48:52 UTC 2009
x86_64 GNU/Linux
oot@tianwei:~# cat /proc/cpuinfo | grep "model name"
model name      : Intel(R) Core(TM)2 Quad CPU    Q6600  @ 2.40GHz


Can anyone point me to the problem? If I send this problem to the wrong
list, let me know.

Thanks.

Tianwei
On Tue, Dec 8, 2009 at 3:12 PM, Tianwei <ti...@gmail.com> wrote:

> Hi, all,
>    I am doing a PMU(performance monitor unit) profiling work on apache now.
> As the first step, I need to find a way to enable and disable the profiling.
> I configure the apache as --with-mpm=worker, by my default configuration,
> it will start 3 child processes(27threads for each process, 25 worker
> threads, 1 listen threads, 1 main server threads). Now I put my start
> function at the entry of "child_main" in mpm/worker/worker.c.  Then during
> serving the request, my code will do a self-monitoring style according to
> the PMU samples. However, I do not know where to put my stop function code.
> The following is my current way:
>   1. I may use "sudo ./bin/apachctl -k stop" to stop the httpd
>   2. normally the "stop" will be caught by the parent process, then it will
> continue to sent "KILL" to child processes
>   3. then for each child process, it will catch the signal from parent
> process and continue to kill all its threads.
> I want to put  my "stop" function at the start of step 3 where each child
> process receive the signals from parent process.
>
> I search the documents and debug the code a lot, but still can not
> understand the signal-handler mechanism in httpd. Can anyone kindly point me
> to the right document or code place where I can insert my stop function?
>
> Thanks very much.
>
> Tianwei
>
> --
> Sheng, Tianwei
> Inst. of High Performance Computing
> Dept. of Computer Sci. & Tech.
> Tsinghua Univ.
>



-- 
Sheng, Tianwei
Inst. of High Performance Computing
Dept. of Computer Sci. & Tech.
Tsinghua Univ.