[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apache-modules
Subject:    Re: [apache-modules] Re: Thread
From:       "Alex \(Oleksiy\) Bolgarov" <oleksiy_alex_bolgarov () yahoo ! com>
Date:       2004-01-13 16:39:17
Message-ID: 20040113163917.23734.qmail () web10105 ! mail ! yahoo ! com
[Download RAW message or body]

 --- Marco Spinetti <m.spinetti@pisa.iol.it> wrote: >
Hi all,
> 
> I have implemented my module: inside it I start 5
> pthreads. Each one 
> starts a different connection.
> 
> I'm using apache 1.3.27.
> 
> My big problem is if I start apache with:
> 
> /usr/local/apache/bin/httpd -X -f
> /usr/local/apache/conf/httpd.conf -c 
> 'Port 80'
> 
> all is ok.
> 
> But if I start apache normally
> (/usr/local/apache/bin/apachectl start) 
> my apache module never returns from
> pthread_cond_wait.


Apache 1.3.X forks child processes to process
requests. You should remember that after fork(), in
the child process only one thread is running - the one
that calls fork() (see man pthread_atfork, or even
better google for pthread_atfork()). I guess you start
therads when you are reading configuration directievs,
right? Those threads are staretd in the parent Apache
process. When Apache decides it needs to start new
child process to process a request, it fork()s, and in
the child process your threads just are not running!

Now, you do not see this when starting Apache with -X
option, because, if I remember correctly, -X means
"run Apache in one process without forking", to
provide nice debug environment for module development.
If you run Apache via apachectl, no -X option is given
to httpd and Apache start forking new processes.

So, this means bacically that you _can_ use threads in
Apache 1.3 module, in a sence that it will compile and
run without crashes, but it usually will not work as
expected.

On the other hand I have very positive experience
using threads in the module for Apache 2 with "worker"
or "perchild" MPMs. You just make sure that you start
threads in the child process, not ini parent during
reading of configuration data.


Thank you, 

    alex.

______________________________________________________________________ 
Post your free ad now! http://personals.yahoo.ca

---------------------------------------------------------------------
To unsubscribe, e-mail: apache-modules-unsubscribe@covalent.net
For additional commands, e-mail: apache-modules-help@covalent.net

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic