[mylvmbackup] Re: script doesn't die on db connect failure

Hi Matthew,

sorry for the late reply, I've been on vacation for the past two weeks and am
on a trade show the entire week, which does not leave me much time to catch up
with my email backlog...

On 10/10/2008 12:10 AM, Boehm, Matthew wrote:

> Just noticed this. If I turn off MySQL and attempt to run the script,
> the "preflush" script will actually run.
> 
> Consider this code from mylvmbackup.pl:192
> 
> my $dbh= DBI->connect($dsn,$user,$password)
>   or log_msg ($DBI::errstr, LOG_ERR) && die $DBI::errstr;
> 
> On DBI->connect() failure, the log_msg() runs, but the die() does not.

Odd, I guess I never actually tested that ;)

> Code execution continues on to the next line which is
> run_hook("preflush");
> 
> Proposed fix. Verified correct behavior.
> 
> my $dbh = DBI->connect($dsn,$user,$password);
> if(!$dbh)
> {
>         log_msg ($DBI::errstr, LOG_ERR);
>         die($DBI::errstr);
> }

Excellent, thanks for the patch! Applied and pushed into trunk.

Bye,
        LenZ
-- 
------------------------------------------------------------------
 Lenz Grimmer <lenz@xxxxxxxxxxx>                             -o)
 [ICQ: 160767607 | Jabber: LenZGr@xxxxxxxxxx]                /\\
 http://www.lenzg.org/                                       V_V

Other related posts: