Hey folks, what can I do to get one of these patches committed? Help me help you :) On Mon, Apr 20, 2009 at 10:33:35AM -0700, eam@frap.net wrote: > I have two patches for this bug - I don't know enough about Perl's handle > internals to know which is more correct. Nicholas pointed out the > problem, that the typemap for OutputStream only reads from OFP, and that > an O_RDONLY handle only populates IFP. It seems that IFP is always > populated even when the handle is read-only, so the first proposed patch > simply changes the arg type (seems very counter-intuitive, are there any > cases where it's wrong?). The second patch tests OFP first, then falls > back to IFP. > > DIRP is ignorable as the type is implementation dependent - a descriptor > cannot be extracted via public libc structures. I'm not sure if there > are any other fields in the handle that should be considered. > > I'm also not sure if there are any cases where a handle to an fsync'able > object might have a differing IFP and OFP. > > diff -ruN perl-5.8.9/ext/IO/IO.xs perl-5.8.9-patched/ext/IO/IO.xs > --- perl-5.8.9/ext/IO/IO.xs 2005-09-06 02:11:32.000000000 -0700 > +++ perl-5.8.9-patched/ext/IO/IO.xs 2009-04-20 09:26:26.000000000 > -0700 > @@ -419,7 +419,7 @@ > > SysRet > fsync(handle) > - OutputStream handle > + InputStream handle > CODE: > #ifdef HAS_FSYNC > if(handle) > > > diff -ruN perl-5.8.9/ext/IO/IO.xs perl-5.8.9-patched/ext/IO/IO.xs > --- perl-5.8.9/ext/IO/IO.xs 2005-09-06 02:11:32.000000000 -0700 > +++ perl-5.8.9-patched/ext/IO/IO.xs 2009-04-20 10:02:46.000000000 > -0700 > @@ -418,13 +418,17 @@ > > > SysRet > -fsync(handle) > - OutputStream handle > +fsync(arg) > + SV * arg > CODE: > #ifdef HAS_FSYNC > - if(handle) > - RETVAL = fsync(PerlIO_fileno(handle)); > - else { > + OutputStream handle = NULL; > + handle = IoOFP(sv_2io(arg)); > + if (!handle) > + handle = IoIFP(sv_2io(arg)); > + if (handle) { > + RETVAL = fsync(PerlIO_fileno(handle)); > + } else { > RETVAL = -1; > errno = EINVAL; > } >Thread Previous