develooper Front page | perl.perl5.porters | Postings from March 2012

[perl #75780] PerlIO::via calls the CLOSE callback too late

From:
Nicholas Clark via RT
Date:
March 28, 2012 09:34
Subject:
[perl #75780] PerlIO::via calls the CLOSE callback too late
Message ID:
rt-3.6.HEAD-4610-1332952466-1432.75780-14-0@perl.org
[and again, as I forgot to cc perl5-porters]

On Tue Jun 15 15:01:13 2010, ikegami@adaelis.com wrote:

> PerlIO::via calls the CLOSE callback too late.

> There are 32 PerlIO::via modules on CPAN. 27 don't define a CLOSE
> handler.

would any break (or break more badly) with this change?

>  IV
>  PerlIOVia_close(pTHX_ PerlIO * f)
>  {
>      PerlIOVia *s = PerlIOSelf(f, PerlIOVia);
> -    IV code = PerlIOBase_close(aTHX_ f);
>      SV *result =
>          PerlIOVia_method(aTHX_ f, MYMethod(CLOSE), G_SCALAR, Nullsv);
> +    IV code = PerlIOBase_close(aTHX_ f);
>      if (result && SvIV(result) != 0)
>          code = SvIV(result);
>      PerlIOBase(f)->flags &= ~(PERLIO_F_RDBUF | PERLIO_F_WRBUF);
>      return code;
>  }

I'm wondering whether *instead*, the change should be to decree
that the CLOSE handler (if present) is responsible for closing the
file handle.

Design-wise is that cleaner? Or does it break more assumptions?


Nicholas Clark




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About