apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Yuri V. Vishnevskiy" <yuri.vishnevs...@gmail.com>
Subject Re: Crash in apr_file_close() (Linux)
Date Fri, 16 Oct 2009 09:21:03 GMT

> 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

Mime
View raw message