My setup is as follows:

Apache/2.0.44 (Gentoo/Linux) mod_perl/1.99_08 Perl/v5.8.0

mod_perl was built from CVS.

I was interested in getting Apache::DBI to run under mp2. I did read 
Ask's message at 
http://marc.theaimsgroup.com/?l=apache-modperl&m=104225578207460&w=2
which leads me to my question. What would it take to get connect_on_init 
to run under mp2?

With the following patch I was able to get connect_on_init to work under 
mp2. Remember that my objective was to JUST get it to run. This is NOT 
release quality code. I'm happy to report that it works for me, so far. 
Anyone else who is running mp2 (no compat mode) willing to give it a try?
Of course, then the gurus can come in and clean up the code so that it 
works under either mp1 or mp2.

diff -u DBI.pm /usr/lib/perl5/site_perl/5.8.0/Apache/DBI.pm 
--- DBI.pm      2003-02-17 08:04:19.000000000 -0500
+++ /usr/lib/perl5/site_perl/5.8.0/Apache/DBI.pm        2003-03-03 
12:03:06.000000000 -0500
@@ -7,6 +7,8 @@
 use DBI ();
 use Carp qw(carp);
 
+use Apache::ServerUtil ();
+
 require_version DBI 1.00;
 
 $Apache::DBI::VERSION = '0.91';
@@ -32,9 +34,8 @@
     # provide a handler which creates all connections during server 
startup
 
     # TODO - Should check for mod_perl 2 and do the right thing there
-    carp "Apache.pm was not loaded\n" and return unless 
$INC{'Apache.pm'};
-    if([EMAIL PROTECTED] and Apache->can('push_handlers')) {
-        Apache->push_handlers(PerlChildInitHandler => \&childinit);
+    if([EMAIL PROTECTED]) {
+        Apache->server->push_handlers(PerlChildInitHandler => 
\&childinit);
     }
     # store connections
     push @ChildConnect, [EMAIL PROTECTED];
@@ -89,9 +90,9 @@
     # this PerlCleanupHandler is supposed to initiate a rollback after 
the script has finished if AutoCommit is off.
     my $needCleanup = ($Idx =~ /AutoCommit[^\d]+0/) ? 1 : 0;
     # TODO - Fix mod_perl 2.0 here
-    if(!$Rollback{$Idx} and $needCleanup and 
Apache->can('push_handlers')) {
+    if(!$Rollback{$Idx} and $needCleanup) {
         print STDERR "$prefix push PerlCleanupHandler \n" if 
$Apache::DBI::DEBUG > 1;
-        Apache->push_handlers("PerlCleanupHandler", \&cleanup);
+        Apache->server->push_handlers("PerlCleanupHandler", \&cleanup);
         # make sure, that the rollback is called only once for every 
         # request, even if the script calls connect more than once
         $Rollback{$Idx} = 1;


--
Haroon Rafique
<[EMAIL PROTECTED]>

Reply via email to