Re: Disconnect database connection after idle timeout

Perrin Harkins <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <CAC0_be2YY+MdL59aj8rvkUcZrpJ6zDvujwACzsj4_xGBj3T9mw@mail.gmail.com>
On Thu, Nov 13, 2014 at 5:29 PM, Vincent Veyron <[email protected]> wrote:

> I stash a reference to a DBI handle in pnotes during the HeaderParser
> phase of my requests; I then refer to this handle for every request in my
> PerlResponseHandlers.
>
> This seems to have been working fine for several months. Am I doing
> something wrong?
>

No, that's perfect. Since pnotes gets cleaned up at the end of every
request, there's no danger of the handle sticking around. I assume you're
calling DBI->connect() to get the handle in the HeaderParser phase, and
using Apache::DBI?

The dangerous thing is to put a DBI handle in a global and just keep using
it on every request. If you put a DBI handle in a global (or a closure
variable) make sure you clean it up at the end of every request.

- Perrin
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.