From 44f55bbbb6e62588ed45092abed74efff97ae539 Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Wed, 29 Aug 2007 16:50:15 +0000 Subject: Wallet::Server is now responsible for connecting to the database. Don't bother working hard to disconnect the database on exit, since the DESTROY DBI method will do the right thing. --- server/wallet-backend | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) (limited to 'server') diff --git a/server/wallet-backend b/server/wallet-backend index 24910cd..e8617cd 100755 --- a/server/wallet-backend +++ b/server/wallet-backend @@ -19,21 +19,6 @@ use Sys::Syslog qw(openlog syslog); use Wallet::Config; use Wallet::Server; -############################################################################## -# Database handling -############################################################################## - -# Open a new database connection. This is a separate function to make it -# easier to override later. -sub db_connect { - my $dsn = "DBI:$DB_DRIVER:database=$DB_NAME;host=$DB_HOST;port=$DB_PORT"; - my $dbh = DBI->connect ($dsn, $DB_USER, $DB_PASSWORD); - if (not defined $dbh) { - die "Cannot connect to database: $DBI::errstr\n"; - } - return $dbh; -} - ############################################################################## # Implementation ############################################################################## @@ -47,12 +32,8 @@ my $user = $ENV{REMOTE_USER} or die "REMOTE_USER not set\n"; my $host = $ENV{REMOTE_HOST} || $ENV{REMOTE_ADDR} or die "Neither REMOTE_HOST nor REMOTE_USER set\n"; -# Open the database connection and close it cleanly on exit. -my $dbh = db_connect; -END { $dbh->disconnect; } - # Instantiate the server object. -my $server = Wallet::Server->new ($dbh, $user, $host); +my $server = Wallet::Server->new ($user, $host); # Parse command-line options and dispatch to the appropriate calls. my ($command, @args) = @ARGV; -- cgit v1.2.3