From d68d98fa943d0eba896e5d216c809b5818ec4fb4 Mon Sep 17 00:00:00 2001 From: Andreas Brachold Date: Wed, 14 May 2008 21:08:28 +0000 Subject: * Losing mysql connection if process fork --- bin/xxvd | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'bin') diff --git a/bin/xxvd b/bin/xxvd index e58f494..ef285cf 100755 --- a/bin/xxvd +++ b/bin/xxvd @@ -328,27 +328,25 @@ sub getDbh { my $dbh = DBI->connect($dsn, $usr, $pwd,{ PrintError => 1, AutoCommit => 1, + mysql_enable_utf8 => ($charset =~ m/UTF-8/ ? 1 : 0), + mysql_auto_reconnect => 1 }); if($dbh) { debug sprintf('Connect to database: %s successful.', $dsn); - if ($charset) { - my $NAMES = { - 'UTF-8' => 'utf8', - 'ISO-8859-1' => 'latin1', - 'ISO-8859-2' => 'latin2', - 'ISO-8859-5' => 'latin5', - 'ISO-8859-7' => 'latin7', - 'ISO-8859-15' => 'latin1', - }; - my $n = $NAMES->{$charset} || 'latin1'; - if (!($dbh->do("set character set '" . $n . "'"))) { - panic sprintf("Could not set charset: %s :", $n, $DBI::errstr); - } - #$dbh->{'mysql_enable_utf8'} = 1 if($n eq 'utf8'); + my $NAMES = { + 'UTF-8' => 'utf8', + 'ISO-8859-1' => 'latin1', + 'ISO-8859-2' => 'latin2', + 'ISO-8859-5' => 'latin5', + 'ISO-8859-7' => 'latin7', + 'ISO-8859-15' => 'latin1', + }; + my $n = $NAMES->{$charset} || 'latin1'; + if (!($dbh->do("set character set '" . $n . "'"))) { + panic sprintf("Could not set charset: %s :", $n, $DBI::errstr); } - $dbh->{'mysql_auto_reconnect'} = 1; } else { panic sprintf("Could not connect to database: %s :", $dsn, $DBI::errstr); &quit(1); -- cgit v1.2.3