develooper Front page | perl.perl5.porters | Postings from December 2001

[patch perlio.c] fixing PerlIOBuf_flush

From:
Stas Bekman
Date:
December 20, 2001 01:28
Subject:
[patch perlio.c] fixing PerlIOBuf_flush
Message ID:
Pine.LNX.4.40.0112201724590.24681-100000@hope.stason.org
Since I'm "subclassing" PerlIOBuf I'm trying to use its methods where I
can. So in my PerlIOAPR_seek I need to flush the PerlIOBuf buffer, or the
next read will be wrong. So I call:

   code = PerlIOBuf_flush(aTHX_ f);

first thing first and it returns -1. This patch makes sure to call the
next layer's flush only if such exists.

is that was the FIXME tag about and can be removed now?

--- perlio.c.orig	Thu Dec 20 17:18:44 2001
+++ perlio.c	Thu Dec 20 17:20:59 2001
@@ -2920,6 +2920,7 @@
 PerlIOBuf_flush(pTHX_ PerlIO *f)
 {
     PerlIOBuf *b = PerlIOSelf(f, PerlIOBuf);
+    PerlIO *n;
     int code = 0;
     if (PerlIOBase(f)->flags & PERLIO_F_WRBUF) {
 	/*
@@ -2961,7 +2962,8 @@
     /*
      * FIXME: Is this right for read case ?
      */
-    if (PerlIO_flush(PerlIONext(f)) != 0)
+    n = PerlIONext(f);
+    if (n && *n && PerlIO_flush(n) != 0)
 	code = -1;
     return code;
 }



_____________________________________________________________________
Stas Bekman             JAm_pH      --   Just Another mod_perl Hacker
http://stason.org/      mod_perl Guide   http://perl.apache.org/guide
mailto:stas@stason.org  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/




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