apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Havard <brian.hav...@gmail.com>
Subject Re: Deadlock with apr_file_open(APR_FOPEN_APPEND) and apr_file_lock() under Windows
Date Sun, 10 Oct 2010 01:34:21 GMT
On 08/10/10 23:21, Stefan Ruppert wrote:
> I have filed a bug in bugzilla for this issue:
>
> https://issues.apache.org/bugzilla/show_bug.cgi?id=50058
>
> and added a patch which simple removes the calls to apr_file_lock()
> and apr_file_unlock()!
>
> Please can some test this!?

As I remember it, the file lock is used to ensure proper appending
behaviour. This is necessary because windows doesn't natively have an
append mode so it's necessary to seek to the end of the file then write.
The file lock is used to prevent a race condition when multiple
threads/processes are writing to the same file simultaneously.

The deadlock problem needs to be solved by suppressing locking for
append if a lock is already held, not by simply removing the locking
completely.



> Stefan Ruppert wrote:
>> Hi all,
>>
>> yesterday I ran into the following problem. I use the apr_file_lock()
>> function in conjunction with the APR_FOPEN_APPEND flag and under
>> Linux everything is fine.
>>
>> Under Windows any attempt to write to the opened and locked file I
>> get a deadlock. This is due the fact that apr_file_write() creates an
>> own lock with apr_file_lock() if the file was opened with the
>> APR_FOPEN_APPEND flag.
>>
>> First this is inconsistent through different operating systems Unix
>> does not lock, Windows does lock the file in append mode. However, I
>> think the locking in the Windows implementation is wrong. The user
>> has to choose if he wants to lock the file or not!
>>
>> To reproduce the behavior please compile and test the attached example!
>>
>> Any comments? Should I file a bug report?
>>
>> Regards,
>> Stefan
>>
>


Mime
View raw message