apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Orton <jor...@redhat.com>
Subject Re: apr_file_gets()/apr_file_read() locking problem
Date Thu, 22 Mar 2007 16:42:03 GMT
On Thu, Mar 22, 2007 at 01:15:21PM +1100, Bojan Smojver wrote:
> I just bumped into this today with 1.2.x, but the code is more or less
> the same in trunk. I opened a temporary file with apr_file_mktemp(),
> which in turn opened an APR file with a mutex (not sure why, but that's
> what happened on FC6 ). So far, so good.
> 
> If apr_file_gets() is called on that file, mutex is locked (line 340 in
> trunk of readwrite.c) in this function. However, this function then
> calls apr_file_read(), which attempts to lock the same mutex again (line
> 45 in trunk of readwrite.c), which hangs the program.

That definitely looks broken.  Either the buffered read code needs to be 
factored out of apr_file_read so it can be called here, or _gets could 
just fall back on the slow !buffered path if flags & APR_XTHREAD (ugly 
but safe).

joe

Mime
View raw message