From owner-svn-src-all@FreeBSD.ORG Tue Jul 22 17:42:51 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8AEE04E8 for ; Tue, 22 Jul 2014 17:42:51 +0000 (UTC) Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com [209.85.217.180]) (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 E675D20A4 for ; Tue, 22 Jul 2014 17:42:50 +0000 (UTC) Received: by mail-lb0-f180.google.com with SMTP id v6so5911176lbi.25 for ; Tue, 22 Jul 2014 10:42:42 -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=sEP8FK3/IytSD/lw18c36wnTbBARHlGVahTWGsazclI=; b=BVkphhA14n3oXFlE55iz3xckjOsH2nQgBzp3dwTeD9WZb+aWyvuNmfMmteSkpOl/p9 YYt+cF5kjROU/KaBY/ta5yWShtDsIC2wYQNf+feK9YgGbD/b0PPxMnMw/g/j/n6Zyi6Q OJc4urvdfegUCHBTEsK7A9gUuWY7wwMxZZRZiQAdj4+eYLJWZLYxchaQ4nV1wjPa85iS IFWQM7porroHrQoxlfa0YsTatH+JIXDDzW7Kyka1yYQlMozlYQMCMR/Mic88y3loO83L 3reXnPRvJEwiII+/R34INyBCgZ/j7VaxbNF7K4KkPIA2MM+oxp0910hTC6IX82JgMO7N vWCg== X-Gm-Message-State: ALoCoQly5CBtTLN3TXZmnsDf1DdEbLY5CoBEBpP6HB/F/Kb+4rYd5Qeevu1cbU7JB6fDjo+4oBsn X-Received: by 10.112.202.39 with SMTP id kf7mr34982350lbc.37.1406050962880; Tue, 22 Jul 2014 10:42:42 -0700 (PDT) Received: from [192.168.1.2] ([89.169.173.68]) by mx.google.com with ESMTPSA id uo5sm1488403lbb.6.2014.07.22.10.42.42 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 22 Jul 2014 10:42:42 -0700 (PDT) Message-ID: <53CEA28A.3040106@freebsd.org> Date: Tue, 22 Jul 2014 21:42:34 +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: r268984 - head/lib/libc/stdio References: <201407221619.s6MGJ10G068003@svn.freebsd.org> <53CE94F6.3090003@freebsd.org> <53CE9A77.4060000@freebsd.org> In-Reply-To: <53CE9A77.4060000@freebsd.org> Content-Type: text/plain; charset=KOI8-R Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Jul 2014 17:42:51 -0000 On 22.07.2014 21:08, Andrey Chernov wrote: > On 22.07.2014 20:44, Andrey Chernov wrote: >> Producing physical writes on ftell cause great performance degradation. >> You should check for __SAPP flag before calling sflush to do this only >> for append-mode files. > > BTW, I believe that sflush() should be completely eliminated even for > _SAPP case. Something like that instead: Proper patch to the old version: --- ftell.c.bak 2014-07-22 21:25:46.000000000 +0400 +++ ftell.c 2014-07-22 21:28:01.000000000 +0400 @@ -118,6 +118,11 @@ 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 Forget the code below, it breaks reading: > if (fp->_flags & __SAPP) { > pos = _sseek(fp, (fpos_t)0, SEEK_END); > if (pos == -1) > return (1); > } else if (fp->_flags & __SOFF) > pos = fp->_offset; > else { > pos = _sseek(fp, (fpos_t)0, SEEK_CUR); > if (pos == -1) > return (1); > } > >> >> On 22.07.2014 20:19, Pedro F. Giffuni wrote: >>> Author: pfg >>> Date: Tue Jul 22 16:19:01 2014 >>> New Revision: 268984 >>> URL: http://svnweb.freebsd.org/changeset/base/268984 >>> >>> Log: >>> ftello: return 1 when seeking offset on an append stream. >>> >>> Obtained from: Apple Inc. (Libc 997.90.3) >>> Phabric: D442 >>> 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 16:10:56 2014 (r268983) >>> +++ head/lib/libc/stdio/ftell.c Tue Jul 22 16:19:01 2014 (r268984) >>> @@ -97,6 +97,8 @@ _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 { >>> >> >> > > -- http://ache.vniz.net/