Here is my file (referred to below as /home/msouth/disconnect.pl):
#!perl -w use strict; use DBI; my $dbh = DBI->connect('dbi:mysql:database=msouth_reg_db;host=redacted +.example.com', 'user', 'pass'); my $rc = $dbh->disconnect; warn "dbh->disconnect returned [$rc]\n"; if (my $ping_val = $dbh->ping) { warn 'here is the thread id ['. $dbh->{mysql_thread_id} ."]\n"; warn "ping returned [$ping_val]\n"; warn "here are Apache-matching keys \%INC:". join "\n", grep {/Apa +che/} keys %INC; } else { warn "ping returned [$ping_val]"; }
if i run this from the command line, it prints what I expect:
dbh->disconnect returned [1] ping returned [] at /home/msouth/disconnect.pl line 14.
If it runs via a "PerlRequire" in my apache conf:
ErrorLog /home/msouth/local/apache/logs/error.log LockFile /home/msouth/local/apache/logs/httpd.lock PidFile /home/msouth/local/apache/logs/httpd.pid # Mod-perl <IfModule mod_perl.c> PerlRequire /home/msouth/disconnect.pl </IfModule> Port 8106
the output upon starting apache is as follows:
dbh->disconnect returned [1] here is the thread id [774516] ping returned [1] here are Apache-matching keys %INC: at /home/msouth/disconnect.pl line + 11.
(new edit with additional information)

I found that, when the disconnect() fails, I can see from mysql's "show processlist" that that the thread with that id is indeed still connected. In my application, I need the threads to disconnect so they will not use resources on the server.



Perl version is 5.8.3, Apache 1.3.33, mod_perl 1.29

Also, I apparently posted this here after not waiting long enough on #perl. Sorry about that.

In reply to disconnect, then ping returns true under apache, false from command line, no Apache::DBI around. Why would this be? by msouth

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.