in reply to Re: Re: using multiple packages w/1 database connection
in thread using multiple packages w/1 database connection

When the program exits all file handles closed by the OS. That should close the socket for the database connection. The Perl code that cleans up might not get run. I guess some database servers could sit there waiting until they get an explicit close command and not notice that the client disappeared.

Recent versions of DBI include an END block that does a disconnect_all and closes all database connections. Also, the DESTROY is supposed to call rollback before the disconnect. Doing a rollback in the END block is the safest thing otherwise some unknown, possibly failed, transaction could be committed.

Replies are listed 'Best First'.
Re: Re: Re: Re: using multiple packages w/1 database connection
by tachyon (Chancellor) on Sep 23, 2003 at 02:20 UTC

    Yes I know that is supposed to happen. Truth be known this is really more of a mod_perl problem, but it actually applies to any long running perl process that has within it code in the form sub { my $dbh = DBI->connect.... }. Under mod_perl for example the combination of lazy garbage collection and ongoing runtime mean the DESTROY and END blocks (respectively) never get called. It was a real problem we had porting to mod_perl which is why I mention it.

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print