On 22.07.2014 22:38, Pedro F. Giffuni wrote: > Author: pfg > Date: Tue Jul 22 18:37:59 2014 > New Revision: 268987 > URL: http://svnweb.freebsd.org/changeset/base/268987 > > Log: > Revert r268984: > Check for __SAPP flag before calling sflush. This avoids > performance degradation compared to the previous approach.
Thanx. In this version sflush which doing physical write is never called, only _sseek (lseek) for __SAPP. Here is the test program, run it several times and notice ftell position increased from time to time (or not in our old version): #include <stdio.h> int main(int argc, char *argv[]) { FILE *fp = fopen("testfile", "a"); rewind(fp); fwrite("1", 1, 1, fp); printf("%ld\n", ftell(fp)); fclose(fp); } It probably worth to be added to our test framework, but I completely unaware how to do it. > > Submitted by: ache > MFC after: 2 weeks > > Modified: > head/lib/libc/stdio/ftell.c > > Modified: head/lib/libc/stdio/ftell.c > ============================================================================== > --- head/lib/libc/stdio/ftell.c Tue Jul 22 17:30:05 2014 > (r268986) > +++ head/lib/libc/stdio/ftell.c Tue Jul 22 18:37:59 2014 > (r268987) > @@ -97,8 +97,6 @@ _ftello(FILE *fp, fpos_t *offset) > * Find offset of underlying I/O object, then > * adjust for buffered bytes. > */ > - if (__sflush(fp)) /* may adjust seek offset on append stream */ > - return (1); > if (fp->_flags & __SOFF) > pos = fp->_offset; > else { > @@ -120,6 +118,11 @@ _ftello(FILE *fp, fpos_t *offset) > if (HASUB(fp)) > pos -= fp->_r; /* Can be negative at this point. */ > } else if ((fp->_flags & __SWR) && fp->_p != NULL) { > + if (fp->_flags & __SAPP) { > + pos = _sseek(fp, (fpos_t)0, SEEK_END); > + if (pos == -1) > + return (1); > + } > /* > * Writing. Any buffered characters cause the > * position to be greater than that in the > -- http://ache.vniz.net/ _______________________________________________ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"