[LA.pm] Apache::DBI pings

Ask Bjørn Hansen ask at develooper.com
Wed Jul 13 07:26:39 PDT 2005


On May 16, 2005, at 3:24 PM, Kevin Scaldeferri wrote:

> I was reading through Apache::DBI... you know, for fun... and there  
> was
> something about this snippet that confused me:
>
> [....]
>
> I had always assumed that the ping happened every N seconds, but I  
> came
> to realize that it's only if it's been more than N seconds since the
> last query.  Of course, it turns out it's actually documented that  
> that
> is the case:

I was going to make it an option, but I couldn't figure out when the  
old behavior would be what you want, so in the next version I'm  
changing it as seen below.

  - ask

===================================================================
--- DBI.pm      (revision 1401)
+++ DBI.pm      (working copy)
@@ -110,7 +110,6 @@
                     and (($now - $LastPingTime{$dsn}) >= $PingTimeOut 
{$dsn})
                    ) ? 1 : 0;
      print STDERR "$prefix need ping: ", $needping == 1 ? "yes" :  
"no", "\n" if $Apache::DBI::DEBUG > 1;
-    $LastPingTime{$dsn} = $now;
      # check first if there is already a database-handle cached
      # if this is the case, possibly verify the database-handle
@@ -118,6 +117,7 @@
      # handle in order to avoid problems (dying inside ping) when
      # RaiseError being on and the handle is invalid.
      if ($Connected{$Idx} and (!$needping or eval{$Connected{$Idx}- 
 >ping})) {
+       $LastPingTime{$dsn} = $now;
          print STDERR "$prefix already connected to '$Idx'\n" if  
$Apache::DBI::DEBUG > 1;
          return (bless $Connected{$Idx}, 'Apache::DBI::db');
      }
@@ -344,7 +344,9 @@
using the ping method (default). Setting the timeout < 0 will de- 
activate
the validation of the database handle. This can be used for drivers,  
which
do not implement the ping-method. Setting the timeout > 0 will ping the
-database only if the last access was more than timeout seconds before.
+database if the last ping was more than timeout seconds before.
+Apache::DBI 0.94 and older would ping only if the last access was more
+than timeout seconds before.
For the menu item 'DBI connections' you need to call Apache::Status  
BEFORE
Apache::DBI ! For an example of the configuration order see startup.pl.


-- 
http://www.askbjoernhansen.com/



More information about the Losangeles-pm mailing list