This is really a C API thing, but I was wondering if Apache2::DBI people can help me shed some light on this...
----- Original Message ----- From: "Kent Fitch" To: <[EMAIL PROTECTED]> Sent: Monday, November 18, 2002 5:37 AM Subject: Re: [apache-modules] Persistant MySQL connections in Apache 2 > Hi Issac, > > From: "Issac Goldstand" > Subject: [apache-modules] Persistant MySQL connections in Apache 2 > > > > Hi all, > > I'm a rookie C API programmer (mod_perl was just so much *easier* > most of > > the time :-)), and am working on coding a module to with in my > front-end > > Apache 2/mod_proxy server. The idea of the module is to provide > access to > > the front-end server with a list of "blacklisted" IPs which are stored > in a > > MySQL database. So I'm thinking the module's child_init should open > the > > connection to the MySQL database and then the access_handler can grab > the > > MySQL connection from the child-pool. > > Yes, but beware that in a threaded Apache run-time, there could > be many threads fo execution processing many requests "simultaneously" > in your child process, so you'll have to arrange to lock the > connection whilst a thread is using it and possibly have a pool of them. > > See "Thread Safety" > http://httpd.apache.org/docs-2.0/developer/thread_safety.html > > > But the problem is that I would *like* for the connections to the > database > > be closed before the pool is simply swept clean upon destruction. I > would > > think that that would be a "good thing to do" - maybe I'm wrong... > > Yes - you should register a cleanup function on the > pool you allocate the data structures for the connection(s) > from in your "init". See these notes on pooling (which may be > a bit 1.3-ish and hence out of date, but the ideas are relevant): > > http://httpd.apache.org/docs-2.0/developer/API.html#pools > > and see the apr_pool_cleanup_register api > > Kent Fitch