From dev-return-22436-apmail-apr-dev-archive=apr.apache.org@apr.apache.org Fri Oct 16 09:21:48 2009 Return-Path: Delivered-To: apmail-apr-dev-archive@www.apache.org Received: (qmail 35213 invoked from network); 16 Oct 2009 09:21:48 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 16 Oct 2009 09:21:48 -0000 Received: (qmail 86774 invoked by uid 500); 16 Oct 2009 09:21:47 -0000 Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 86667 invoked by uid 500); 16 Oct 2009 09:21:47 -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 86659 invoked by uid 99); 16 Oct 2009 09:21:47 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Oct 2009 09:21:47 +0000 X-ASF-Spam-Status: No, hits=-2.6 required=5.0 tests=BAYES_00 X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of yuri.vishnevskiy@gmail.com designates 209.85.220.210 as permitted sender) Received: from [209.85.220.210] (HELO mail-fx0-f210.google.com) (209.85.220.210) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Oct 2009 09:21:44 +0000 Received: by fxm6 with SMTP id 6so2116789fxm.43 for ; Fri, 16 Oct 2009 02:21:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:content-type:to:subject :references:date:mime-version:content-transfer-encoding:from :message-id:in-reply-to:user-agent; bh=+b3mmfzTwATn8oRodcYnmqEsJ4MYsm4iMEJcXTftDLQ=; b=wfCrDwOTSQ/TnPkg31xpAFdYhA//3HTCnDG8Sluvi1/W0GGQ2I0iyXH6YBg7tZzTJR xK0jkgFtreT5S4mAvwZcCuJqhRg+cxpy5nZCCAzQ8/a97bFPD1GA2JxGYthzI1ZMQfYH pFq9cWl1ZQP3whTX+X/Vh6qw+rcNBam2YRQsw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=content-type:to:subject:references:date:mime-version :content-transfer-encoding:from:message-id:in-reply-to:user-agent; b=KtKPtgweqWFuToAfaWkibveP97YEA3bHLKYAdJDXTV/1V7tJv+CPX9EEYHFZcI3z1b T2Nkf7mbRZ26C7hAfHdGpvD1DFE6iAKJGXuTAire1ybbPaOyFd1KKwPV/+4jvdB1qNao 9rGZRFKvMidmUIxKK5Qj1uIHlH0+6kEXsEiyA= Received: by 10.103.76.37 with SMTP id d37mr491297mul.99.1255684883027; Fri, 16 Oct 2009 02:21:23 -0700 (PDT) Received: from r710ft01 ([94.232.26.145]) by mx.google.com with ESMTPS id g1sm1665257muf.5.2009.10.16.02.21.21 (version=SSLv3 cipher=RC4-MD5); Fri, 16 Oct 2009 02:21:22 -0700 (PDT) Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: "Joe Orton" , dev@apr.apache.org Subject: Re: Crash in apr_file_close() (Linux) References: <20091016083949.GA6748@redhat.com> <4AD834B5.4090808@apache.org> <20091016090105.GA6977@redhat.com> Date: Fri, 16 Oct 2009 16:21:03 +0700 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: "Yuri V. Vishnevskiy" Message-ID: In-Reply-To: <20091016090105.GA6977@redhat.com> User-Agent: Opera Mail/10.00 (Linux) > On Fri, Oct 16, 2009 at 10:54:13AM +0200, Mladen Turk wrote: >> On 16/10/09 10:39, Joe Orton wrote: >>> >>> It seems like reasonable behaviour that the second apr_file_close() >>> call >>> should fail, though it certainly isn't obvious from reading the docs. >>> How else do you expect it to behave? You cannot close an fd twice. >>> >> >> I suppose it shouldn't crash the apr. >> IMO either second call to open should fail or >> the call to close should fail, but without actually calling the close(). > > I think the reporter meant "fail" when they said "crash". > > I don't see any reason why it would crash on Unix: the first call to > apr_file_close() will set fd->filedes to -1 after calling close(), the > second one will call close(-1) and fail with EBADF. I have two separate file descriptors. Second apr_file_close(file2) will fail even if file2->filedes==1. So I understand that I have to handle such things by myself. But if I can't close second handle why it is possible to open it successfully? Regards, Yura