You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Sami Tikka <sa...@f-secure.com> on 2003/12/29 21:37:15 UTC

Re: Thread terminatinos ?

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