On 6/4/07, Matt Williamson <[EMAIL PROTECTED]> wrote:
Where does the connect_on_init call and the definition of $_db_config go? In startup.pl? Or in the handler module?
You don't need to use connect_on_init, but if you want to, it goes in your startup.pl. All it does is cause new child processes to open a db connection before they accept any requests, which keeps the first person to hit that process from having to wait for the connect.
Is the startup.pl code run once then shared by all threads?
Are you using threads? On non-Windows systems you will typically want the prefork MPM, so these will be processes rather than threads. The startup.pl code is run once at startup when you call it from your httpd.conf. Since all processes fork from this parent process, any data initialized here will be seen be all children.
What about code that is in the handler module but not in the handler subroutine? Eg the module loads etc. Are they called once per thread up to maxthreads? Or just once per module load and shared between the threads.
That code gets run every time the module is compiled, so it happens once if you do it in the parent before forking or once per child if you don't load the module until after the fork. I believe this is pretty much the same with threads, but I'm not positive. There's some discussion of how threads work with regard to compiling and copying data in the list archives, mostly contributed by Liz who wrote this useful article on the subject: http://www.perlmonks.org/index.pl?node_id=288022 - Perrin