Return-Path: X-Original-To: apmail-apr-dev-archive@www.apache.org Delivered-To: apmail-apr-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5870A105BE for ; Wed, 4 Dec 2013 22:14:21 +0000 (UTC) Received: (qmail 28899 invoked by uid 500); 4 Dec 2013 22:14:21 -0000 Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 28837 invoked by uid 500); 4 Dec 2013 22:14:21 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Id: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 28829 invoked by uid 99); 4 Dec 2013 22:14:21 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Dec 2013 22:14:21 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy includes SPF record at spf.trusted-forwarder.org) Received: from [173.201.193.109] (HELO p3plsmtpa08-08.prod.phx3.secureserver.net) (173.201.193.109) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Dec 2013 22:14:15 +0000 Received: from hub ([76.252.112.72]) by p3plsmtpa08-08.prod.phx3.secureserver.net with id xaDt1m00A1Zmh9Y01aDug1; Wed, 04 Dec 2013 15:13:54 -0700 Date: Wed, 4 Dec 2013 16:13:36 -0600 From: "William A. Rowe Jr." To: dev@apr.apache.org Subject: Re: buffered files read after apr_file_close()'ed Message-ID: <20131204161336.112193dc@hub> In-Reply-To: <529DF0DD.8090606@myarm.com> References: <529BD5B2.5070803@apache.org> <20131202173739.1ce0d204@hub> <529D9356.8080500@myarm.com> <529DDF84.4050703@myarm.com> <529DF0DD.8090606@myarm.com> X-Mailer: Claws Mail 3.9.2 (GTK+ 2.24.22; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org On Tue, 03 Dec 2013 15:55:25 +0100 Stefan Ruppert wrote: > Am 03.12.2013 15:15, schrieb Daniel Lescohier: > > > However, the functions still need to change to return errors for the > > cases when they are unbuffered files. The buffer won't be > > referenced (and cause a crash) in those cases. > > But in this case the OS will return an EBADF if read() or write() is > called. Correct, provided we've set fd = -1 (in case a new file has been opened with the prior fd assignment). On windows, INVALID_HANDLE value would accomplish the same thing, while NULL'ing out the mutex will avoid the reported issue, and we can simply toggle a buffered file to false to cause i/o to occur (and fail). This adds three assignment ops to the close operation, and no cpu ops to all the common read/write/test cases, which is the best all-around solution IMHO. The reason to solve, following Brane's initial comments, is that as our devs live on Windows, or Linux, or OS/X or wherever, that things should try and fail in a somewhat consistent manner, to let those persistent devs track down their bugs.