You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by "Philip M. Gollucci" <pg...@p6m7g8.com> on 2005/04/10 04:21:13 UTC

[PATCH[ Apache::DBI allow to work with mp2 after rename

FYI: Apache::DBI passes all tests on FBSD6.0-current/i386
w/bleedper w/ithreads and the latest bitkeeper checkout of mysql5.0.3a

Thanks

P.S
   sorry for the cross post I wasn't quite sure where to send this one

-- 
END
------------------------------------------------------
Philip M. Gollucci (pgollucci@p6m7g8.com) 301.254.5198
Consultant / http://p6m7g8.net/Resume/resume.shtml
Senior Developer / Liquidity Services, Inc.
	http://www.liquidityservicesinc.com

Re: [PATCH[ Apache::DBI part 2

Posted by "Philip M. Gollucci" <pg...@p6m7g8.com>.
Philip M. Gollucci wrote:
> This only gets it to appear in the Apache::Status menu.
> I believe I'll have a patch to use Apache2::ServerRecUtil
> in the rest shortly.
> 
--- DBI.pm	Sun Apr 10 03:08:50 2005
+++ DBI.pm.new	Sun Apr 10 03:10:56 2005
@@ -31,11 +31,19 @@
  sub connect_on_init {
      # 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(!@ChildConnect and Apache->can('push_handlers')) {
-        Apache->push_handlers(PerlChildInitHandler => \&childinit);
-    }
+		if ($ENV{MOD_PERL_API_VERSION} == 2) {
+			if (!@ChildConnect) {
+				require Apache2::ServerUtil;
+				my $s = Apache2::ServerUtil->server;
+				$s->push_handlers(PerlChildInitHandler => \&childinit);
+			}
+		}
+		else {
+   		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);
+   		}
+		}
      # store connections
      push @ChildConnect, [@_];
  }
@@ -93,10 +101,16 @@

      # 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')) {
          print STDERR "$prefix push PerlCleanupHandler \n" if 
$Apache::DBI::DEBUG > 1;
-        Apache->push_handlers("PerlCleanupHandler", \&cleanup);
+				if ($ENV{MOD_PERL_API_VERSION} == 2) {
+					require Apache2::ServerUtil;
+					my $s = Apache2::ServerUtil->server;
+					$s->push_handlers("PerlCleanupHandler", \&cleanup);
+				}
+				else {
+        	Apache->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;
@@ -191,25 +205,8 @@
    };
  }

-- 
END
------------------------------------------------------
Philip M. Gollucci (pgollucci@p6m7g8.com) 301.254.5198
Consultant / http://p6m7g8.net/Resume/resume.shtml
Senior Developer / Liquidity Services, Inc.
	http://www.liquidityservicesinc.com

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


Re: [PATCH[ Apache::DBI part 2

Posted by "Philip M. Gollucci" <pg...@p6m7g8.com>.
Philip M. Gollucci wrote:
> This only gets it to appear in the Apache::Status menu.
> I believe I'll have a patch to use Apache2::ServerRecUtil
> in the rest shortly.
> 
--- DBI.pm	Sun Apr 10 03:08:50 2005
+++ DBI.pm.new	Sun Apr 10 03:10:56 2005
@@ -31,11 +31,19 @@
  sub connect_on_init {
      # 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(!@ChildConnect and Apache->can('push_handlers')) {
-        Apache->push_handlers(PerlChildInitHandler => \&childinit);
-    }
+		if ($ENV{MOD_PERL_API_VERSION} == 2) {
+			if (!@ChildConnect) {
+				require Apache2::ServerUtil;
+				my $s = Apache2::ServerUtil->server;
+				$s->push_handlers(PerlChildInitHandler => \&childinit);
+			}
+		}
+		else {
+   		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);
+   		}
+		}
      # store connections
      push @ChildConnect, [@_];
  }
@@ -93,10 +101,16 @@

      # 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')) {
          print STDERR "$prefix push PerlCleanupHandler \n" if 
$Apache::DBI::DEBUG > 1;
-        Apache->push_handlers("PerlCleanupHandler", \&cleanup);
+				if ($ENV{MOD_PERL_API_VERSION} == 2) {
+					require Apache2::ServerUtil;
+					my $s = Apache2::ServerUtil->server;
+					$s->push_handlers("PerlCleanupHandler", \&cleanup);
+				}
+				else {
+        	Apache->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;
@@ -191,25 +205,8 @@
    };
  }

-- 
END
------------------------------------------------------
Philip M. Gollucci (pgollucci@p6m7g8.com) 301.254.5198
Consultant / http://p6m7g8.net/Resume/resume.shtml
Senior Developer / Liquidity Services, Inc.
	http://www.liquidityservicesinc.com

Re: [PATCH[ Apache::DBI allow to work wi tth mp2 after rename

Posted by "Philip M. Gollucci" <pg...@p6m7g8.com>.
> 
> --- DBI.pm	Sat Apr  9 22:14:03 2005
> +++ DBI.pm.new	Sat Apr  9 22:17:05 2005
> @@ -193,8 +193,8 @@
>  
>  
>  # prepare menu item for Apache::Status
> -
> -Apache::Status->menu_item(
> +if ($ENV{MOD_PERL_API_VERSION} == 2) {
> +	Apache2::Status->menu_item(
>      'DBI' => 'DBI connections',
>      sub {
>          my($r, $q) = @_;
> @@ -205,10 +205,25 @@
>          push @s, '</TABLE>';
>          return \@s;
>     }
> -
> -) if ($INC{'Apache.pm'}                      # is Apache.pm loaded?
> +	) if Apache2::Module::loaded('Apache2::Status');
> +}
> +else {
> +	## mp 1
> +	Apache::Status->menu_item(
> +    'DBI' => 'DBI connections',
> +    sub {
> +        my($r, $q) = @_;
> +        my(@s) = qw(<TABLE><TR><TD>Datasource</TD><TD>Username</TD></TR>);
> +        for (keys %Connected) {
> +            push @s, '<TR><TD>', join('</TD><TD>', (split($;, $_))[0,1]), "</TD></TR>\n";
> +        }
> +        push @s, '</TABLE>';
> +        return \@s;
> +   }
> +	) if ($INC{'Apache.pm'}                     # is Apache.pm loaded?
>        and Apache->can('module')               # really?
>        and Apache->module('Apache::Status'));  # Apache::Status too?
> +}
>  
>  1;
This only gets it to appear in the Apache::Status menu.
I believe I'll have a patch to use Apache2::ServerRecUtil
in the rest shortly.

-- 
END
------------------------------------------------------
Philip M. Gollucci (pgollucci@p6m7g8.com) 301.254.5198
Consultant / http://p6m7g8.net/Resume/resume.shtml
Senior Developer / Liquidity Services, Inc.
	http://www.liquidityservicesinc.com

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