modperl-mysterious_use_of_null_error_trapping_to_undo_someone_elses

This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.



To: "Andrei A. Voropaev" <andrei@securities.com>
From: Stas Bekman <stas@stason.org>
Subject: Re: Slightly OT: DBD::Oracle::ping
Date: Tue, 20 Nov 2001 19:15:52 +0800

Andrei A. Voropaev wrote:

> Hi!
> 
> In the code for DBD::Oracle::db::ping method there are lines 
> 
>     local $SIG{__DIE__};
>     local $SIG{__WARN__};
> 
> As I understand these lines don't do anything though I guess they are supposed
> to suppress warning messages and possibly 'die' messages. Currently everytime
> when ping fails and we have PrintError => 1 then the message goes into Apache error
> log. What is worse if $dbh was disconnected then ping dies and kills the whole
> process. As temporary fix we can user $dbh->{RaiseError} = 0, but then we'd
> have to rewrite the code that was placed into eval blocks.
> 
> Is this a feature or something that should be fixed? Was it supposed to be 
> 
>    local $SIG{__WARN__} = sub {};

That simply means that any die/warn handlers that the running code may 
have set, are unset in the given scope. Therefore if there code wants to 
print a warning or the code die()'s, the *default* handler will be used.

I think this is mostly used for protection from user-defined sighadler 
which may have an ill-effect during eval {} blocks. See
http://perl.apache.org/guide/perl.html#Exception_Handling_for_mod_perl

I'm not familiar with DBD::Oracle, but you may need to run the faulty 
code in the eval {} block to prevent die-ing.


===

the rest of The Pile (a partial mailing list archive)

doom@kzsu.stanford.edu