On Thu, Dec 14, 2006 at 08:14:12AM -0800, Dean Arnold wrote:
> Tim Bunce wrote:
> >
> >sv_2io never returns false, it croaks. But since you're only calling it
> >if SvROK is true, and the croak error is meaningful ("Bad filehandle ...")
> >I think that's fine.  Also, IoOFP(io) might be false in some odd cases.
> >
> >So I'd suggest a slight tweak:
> >
> >      if (SvROK(file)) {    /* assume it's a filehandle */
> >          io = sv_2io(file);  /* will croak if not */
> >          if (!io || !(fp = IoOFP(io))) {
> >              warn("DBI trace filehandle is not valid");
> >              return 0;
> >          }
> >      }
> >      else { ... }
> 
> OK, thnx. BTW: Does something need to be refcnt'd here ? It occurs
> to me that an app could code something odd and pass a handle
> that would go out of scope, leaving DBI with a bogus handle,
> unless we refcnt it.

Good question. I don't know. Ask on perl5-porters (and cc me).

> Question is, what's refcntable ? io ? If so, we need an add'l
> slot in DBIS to save it (so it can be decremented/discarded,
> rather than PerlIO_close, when a close would normally occur).
>
> BTW: I also swiped the U16 spare_pad variable from DBIS to
> make a "logfp_is_ours" flag which gets set when DBI PerlIO_open's
> the logfile, and cleared when it gets set to STDERR/STDOUT, or
> the input is a filehandle, so DBI doesn't attempt to close
> a filehandle it didn't open.

I'd call it logfp_needs_close to be less ambiguous.

> >Will need some tests of course. Both for writing to a plain filehandle
> >and a tied one.
> >
> 
> Did that last night, along w/ some POD updates.

Great! Thanks Dean.

Tim.

Reply via email to