You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Nasko <at...@atlanticsky.com> on 2003/12/11 10:25:08 UTC
Thread terminatinos ?
Hello everyone.
I have Apache 2 module running under Windows.In each Apache's thread I have a separate ODBC connection to a database.
I want when a thread is destoyed for some reason to close that connection too.
My questions are :
1) What could be a reason for one Apache thread to be terminated
2) How can I be notified when a thread is destroyed so I can close the DB connection
Thanks in advance.
Regards,
Nasko
Re: Thread terminatinos ?
Posted by Sami Tikka <sa...@f-secure.com>.
On Thu, Dec 11, 2003 at 11:25:08AM +0200, Nasko wrote:
> 2) How can I be notified when a thread is destroyed so I can close the DB connection
I think the correct way to do this would be to start a database thread
in child_init and register a thread shutdown callback with the pool
that is passed as parameter to to child_init. This pool is a "child"
pool and there is one in every "worker", be they processes or threads.
Child_init is a callback which is called right after creation of a
worker. When the pool is destroyed (because the worker is shut down),
the callbacks registered with the pool are called.
See ap_hook_child_init() and apr_pool_cleanup_register()
(Hmm... what is the correct terminology? Should I talk about children?
But that sort of implies that they are processes whereas on Windows
they are threads. I've used the word "worker" but perhaps someone
could confuse that with the child processes of the Worker MPM.)
--
Sami Tikka tel: +358 9 2520 5115
Senior Software Engineer fax: +358 9 2520 5013
F-Secure Corporation http://www.F-Secure.com/
F-Secure: Securing the Mobile, Distributed Enterprise
Re: Thread terminatinos ?
Posted by Jeff White <jl...@earthlink.net>.
From: "Nick Kew"
> > Hello everyone.
> > I have Apache 2 module running under Windows.In each Apache's
> thread I have a separate ODBC connection to a database.
>
> Why every thread? Wouldn't it be more efficient to share a
connection
> pool between your threads? You might possibly want to look at
mod_pg_pool
> (at http://apache.webthing.com/ ) as a template for that.
>
Or the many other ways!
> > My questions are :
>
> Can't answer them.
>
> ICBW, but AIUI threads in your MPM are merely an implementation of
> Apache's abstract architecture, so if you tie something to them,
> you're more-or-less fighting against the architecture. That means
> your module is likely to be non-portable and at risk of breaking on
> future Apache updates.
>
Really define MPM?
<quote>
"...the purpose of MPMs is to improve
performance on specific platforms."
</quote>
Ryan Bloom the "creator" of Apache2!
> 1) What could be a reason for one
> Apache thread to be terminated
The thread did what it was suppose to
and returned or timed out or ????
> 2) How can I be notified when a thread
> is destroyed so I can close the DB connection
Forgetting the database "issues" here is
how thread tracking on Windows can be
done.
You can do all this in any computer
language but for all to follow along,
in Windows Scripting:
Windows Scripting with VBScript scripts.
Adjust the scripts to your needs, then save
the VBScript script file to any folder. Then
in a command prompt window set to the
VBScript script's folder, use the Windows
Script Host (WSH) engine cscript.exe
by typing:
cscript.exe VBScriptFileName.vbs
Remember one can also use the script
language of your desire with the Windows
Script Host (WSH) engines.
Monitoring Threads
http://www.microsoft.com/technet/scriptcenter/scrguide/sas_prc_kfqh.asp
MSDN - The WMI Win32_Thread Class
http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_thread.asp
MSDN - The WMI Win32_Process Class
http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_process.asp
The TechNet Script Center
http://www.microsoft.com/technet/scriptcenter
An ONLINE version of the 1328 page Scripting Guide:
Microsoft Windows 2000 Scripting Guide
http://www.microsoft.com/technet/scriptcenter/scrguide/sagsas_overview.asp
Jeff
Re: Thread terminatinos ?
Posted by Nick Kew <ni...@webthing.com>.
On Thu, 11 Dec 2003, Nasko wrote:
(can you please fix your mailer to post text and use a sensible
line length?)
> Hello everyone.
> I have Apache 2 module running under Windows.In each Apache's
thread I have a separate ODBC connection to a database.
Why every thread? Wouldn't it be more efficient to share a connection
pool between your threads? You might possibly want to look at mod_pg_pool
(at http://apache.webthing.com/ ) as a template for that.
> My questions are :
Can't answer them.
ICBW, but AIUI threads in your MPM are merely an implementation of
Apache's abstract architecture, so if you tie something to them,
you're more-or-less fighting against the architecture. That means
your module is likely to be non-portable and at risk of breaking on
future Apache updates.
--
Nick Kew
In urgent need of paying work - see http://www.webthing.com/~nick/cv.html