perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Clinton Gormley <cl...@traveljury.com>
Subject Re: mod_perl2 DBI handle freshining problem solved "once and for all"...
Date Wed, 01 Feb 2006 23:43:27 GMT

> Apache::DBI doesn't cache handles that you open during startup or
> prevent you from calling disconnect on them.  If you have it loaded
> correctly and you don't call disconnect on handles opened in startup,
> you should see warnings about the handles being DESTROYed without
> disconnect.  If you don't see those, it means you are caching the
> handles somewhere in your own code.

That is now what I have seen in mp2.  In fact the code that (according
to the comments) is supposed to do that, does nothing but avoid
connecting to the DB on the very first start. (when restart count == 1)

The parent server immediately restarts and those connections ARE cached
and lead to the problems of shared handles.

A few days ago I proposed a patch to Apache::DBI which handles the issue
for mp2:

--- 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;



Mime
View raw message