Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Jul 2014 18:38:00 +0000 (UTC)
From:      "Pedro F. Giffuni" <pfg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r268987 - head/lib/libc/stdio
Message-ID:  <201407221838.s6MIc0i9032540@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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.
  
  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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201407221838.s6MIc0i9032540>