perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fred Moyer <f...@redhotpenguin.com>
Subject Fwd: svn commit: r907292 - in /perl/Apache-DBI/trunk: Changes lib/Apache/DBI.pm
Date Sun, 07 Feb 2010 00:33:51 GMT
Should I put together 1.09?


---------- Forwarded message ----------
From:  <phred@apache.org>
Date: Sat, Feb 6, 2010 at 12:24 PM
Subject: svn commit: r907292 - in /perl/Apache-DBI/trunk: Changes
lib/Apache/DBI.pm
To: modperl-cvs@perl.apache.org


Author: phred
Date: Sat Feb  6 20:24:30 2010
New Revision: 907292

URL: http://svn.apache.org/viewvc?rev=907292&view=rev
Log:
Add childexithandler to prevent database connection warnings when the httpd
child exits.

Submitted by: Nick Wellnhofer<wellnhofer@aevum.de>
Reviewed by: Fred Moyer
Tested by: Fred Moyer, Adam Prime

http://marc.info/?l=apache-modperl-dev&m=124824443220933&w=2

Modified:
   perl/Apache-DBI/trunk/Changes
   perl/Apache-DBI/trunk/lib/Apache/DBI.pm

Modified: perl/Apache-DBI/trunk/Changes
URL: http://svn.apache.org/viewvc/perl/Apache-DBI/trunk/Changes?rev=907292&r1=907291&r2=907292&view=diff
==============================================================================
--- perl/Apache-DBI/trunk/Changes (original)
+++ perl/Apache-DBI/trunk/Changes Sat Feb  6 20:24:30 2010
@@ -1,6 +1,8 @@
 Revision history for ApacheDBI.

 1.09
+  - Adds PerlChildExitHandler to disconnect existing connections
+    Submitted by: Nick Wellnhoffer <wellnhofer@aevum.de>

 1.08 February 3rd, 2010
  - Fix bug to allow DBI in startup.pl etc again

Modified: perl/Apache-DBI/trunk/lib/Apache/DBI.pm
URL: http://svn.apache.org/viewvc/perl/Apache-DBI/trunk/lib/Apache/DBI.pm?rev=907292&r1=907291&r2=907292&view=diff
==============================================================================
--- perl/Apache-DBI/trunk/lib/Apache/DBI.pm (original)
+++ perl/Apache-DBI/trunk/lib/Apache/DBI.pm Sat Feb  6 20:24:30 2010
@@ -39,6 +39,9 @@
                                #   a negative value de-activates ping,
                                #   default = 0
 my %LastPingTime;               # keeps track of last ping per data_source
+my $ChildExitHandlerInstalled;  # set to true on installation of
+                                # PerlChildExitHandler
+my $InChild;

 # Check to see if we need to reset TaintIn and TaintOut
 my $TaintInOut = ($DBI::VERSION >= 1.31) ? 1 : 0;
@@ -134,6 +137,23 @@
        }
    }

+    # this PerlChildExitHandler is supposed to disconnect all open
+    # connections to the database
+    if (!$ChildExitHandlerInstalled) {
+        $ChildExitHandlerInstalled = 1;
+        my $s;
+        if (MP2) {
+            $s = Apache2::ServerUtil->server;
+        }
+        elsif (Apache->can('push_handlers')) {
+            $s = 'Apache';
+        }
+        if ($s) {
+            debug(2, "$prefix push PerlChildExitHandler");
+            $s->push_handlers(PerlChildExitHandler => \&childexit);
+        }
+    }
+
    # this PerlCleanupHandler is supposed to initiate a rollback after the
    # script has finished if AutoCommit is off.  however, cleanup can only
    # be determined at end of handle life as begin_work may have been called
@@ -218,6 +238,22 @@
    1;
 }

+# The PerlChildExitHandler disconnects all open connections
+sub childexit {
+
+    my $prefix = "$$ Apache::DBI            ";
+    debug(2, "$prefix PerlChildExitHandler");
+
+    foreach my $dbh (values(%Connected)) {
+        eval { DBI::db::disconnect($dbh) };
+        if ($@) {
+            debug(2, "$prefix DBI::db::disconnect failed - $@");
+        }
+    }
+
+    1;
+}
+
 # The PerlCleanupHandler is supposed to initiate a rollback after the script
 # has finished if AutoCommit is off.
 # Note: the PerlCleanupHandler runs after the response has been sent to

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Mime
View raw message