From owner-svn-src-head@FreeBSD.ORG Tue Jul 22 19:09:01 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8E7F9ED0 for ; Tue, 22 Jul 2014 19:09:01 +0000 (UTC) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com [209.85.215.54]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0E8FE2959 for ; Tue, 22 Jul 2014 19:09:00 +0000 (UTC) Received: by mail-la0-f54.google.com with SMTP id el20so79532lab.27 for ; Tue, 22 Jul 2014 12:08:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=k+jpCkUZs1TGsEZtmtcwW3WMdu3GPjVIi3RIS4q7IRw=; b=CnR1o75P+YwM+GTls6r4PM5wHaOAdsJOpneBhuXmEe9L7ezLhs7u7/HpG2fmwxw7Rn KATDhLBqkkDHueG+qG/nT6GzodGwX/qcINku+P6N4TPcgjWDGDURQ/iVzaBoxn+9ABWL sCbkPLUqTTNTwDh+FtzyyElQLGhqQtrP4YywrryRETeMzereNFkQc/VHrUe8+4AVbIsh 3jdC8dINO5ZIjPpqoQt1Ss9GFTLTUxgWea0ouvBZCmm0WhMoV94jGzMxa0cVOjDr0C2/ ioJGq6MaTJG31HN8XxWlBzrqZ8aPOYlw/qtUWCOB98OWeChihq9mPMg3n7RvUFFNkKyr IikA== X-Gm-Message-State: ALoCoQlVoXBTvkPOGjX8O0ZGSvHnDAjFOMsZZO4ar8euh+wAxUF5LW3pztFt2gEHRBDw2iZL97ep X-Received: by 10.152.25.132 with SMTP id c4mr14371677lag.88.1406056133274; Tue, 22 Jul 2014 12:08:53 -0700 (PDT) Received: from [192.168.1.2] ([89.169.173.68]) by mx.google.com with ESMTPSA id c7sm1752777lbd.37.2014.07.22.12.08.52 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 22 Jul 2014 12:08:52 -0700 (PDT) Message-ID: <53CEB6BD.3000403@freebsd.org> Date: Tue, 22 Jul 2014 23:08:45 +0400 From: Andrey Chernov User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: "Pedro F. Giffuni" , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r268987 - head/lib/libc/stdio References: <201407221838.s6MIc0i9032540@svn.freebsd.org> In-Reply-To: <201407221838.s6MIc0i9032540@svn.freebsd.org> Content-Type: text/plain; charset=KOI8-R Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Jul 2014 19:09:01 -0000 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 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/