From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32153 invoked by alias); 4 Mar 2014 09:06:37 -0000 Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-owner@sourceware.org Received: (qmail 32098 invoked by uid 48); 4 Mar 2014 09:06:33 -0000 From: "siddhesh at redhat dot com" To: glibc-bugs@sourceware.org Subject: [Bug stdio/16532] fdopen(..., "a"); fwrite(); ftello() sequence gives wrong answer Date: Tue, 04 Mar 2014 09:06:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: stdio X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: siddhesh at redhat dot com X-Bugzilla-Status: RESOLVED X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: siddhesh at redhat dot com X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status resolution Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-03/txt/msg00012.txt.bz2 https://sourceware.org/bugzilla/show_bug.cgi?id=16532 Siddhesh Poyarekar changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |RESOLVED Resolution|--- |FIXED --- Comment #4 from Siddhesh Poyarekar --- Fixed in master: commit 000232b9bcbf194f1e5fd0ff380000f341505405 Author: Siddhesh Poyarekar Date: Tue Mar 4 07:45:58 2014 +0530 Separate ftell from fseek logic and avoid modifying FILE data (#16532) ftell semantics are distinct from fseek(SEEK_CUR) especially when it is called on a file handler that is not yet active. Due to this caveat, much care needs to be taken while modifying the handler data and hence, this first iteration on separating out ftell focusses on maintaining handler data integrity at all times while it figures out the current stream offset. The result is that it makes a syscall for every offset request. There is scope for optimizing this by caching offsets when we know that the handler is active. A simple way to find out is when the buffers have data. It is not so simple to find this out when the buffer is empty without adding some kind of flag. -- You are receiving this mail because: You are on the CC list for the bug.