Skip Menu |
 

This queue is for tickets about the Apache-DBI CPAN distribution.

Report information
The Basics
Id: 17446
Status: resolved
Priority: 0/
Queue: Apache-DBI

People
Owner: Nobody in particular
Requestors: clinton [...] traveljury.com
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.9901
Fixed in: (no value)

Attachments
nocache_during_startup.patch



Subject: Not caching connections during startup
Download (untitled) / with headers
text/plain 984b
Some of my perl modules connect to the database during startup, and I have been getting errors when my children try to connect to the database, because they end up trying to share the $dbh handles from the parent. The current code that tries to prevent handle caching (according to the comments) doesn't do anything except avoid creating connections the first time the server is started. if (MP2) { require Apache2::ServerUtil; if (Apache2::ServerUtil::restart_count() == 1) { print STDERR "....." } } However, the server immediately stops and starts again, and all the handles created in the parent are cached and then shared out to the children. And when the server is restarted, the restart_count just keeps going up - there is now way that I can see of knowing if you are in a restart or not. So instead, I've just forced childinit() to be called whether or not you use connect_on_init and I reset the cache there. Patch attached
Subject: nocache_during_startup.patch
--- Apache/DBI.pm.orig 2006-01-29 01:41:55.000000000 +0100 +++ Apache/DBI.pm 2006-01-29 01:43:34.000000000 +0100 @@ -11,6 +11,8 @@ require mod_perl2; require Apache2::Module; require Apache2::ServerUtil; + my $s = Apache2::ServerUtil->server; + $s->push_handlers(PerlChildInitHandler => \&childinit); } elsif (defined $modperl::VERSION && $modperl::VERSION > 1 && $modperl::VERSION < 1.99) { @@ -45,13 +47,7 @@ sub connect_on_init { # provide a handler which creates all connections during server startup - if (MP2) { - if (!@ChildConnect) { - my $s = Apache2::ServerUtil->server; - $s->push_handlers(PerlChildInitHandler => \&childinit); - } - } - else { + unless (MP2) { carp "Apache.pm was not loaded\n" and return unless $INC{'Apache.pm'}; if (!@ChildConnect and Apache->can('push_handlers')) { Apache->push_handlers(PerlChildInitHandler => \&childinit); @@ -188,6 +184,7 @@ sub childinit { my $prefix = "$$ Apache::DBI "; print STDERR "$prefix PerlChildInitHandler \n" if $Apache::DBI::DEBUG > 1; + %Connected = (); if (@ChildConnect) { for my $aref (@ChildConnect) { shift @$aref;


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.