You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Bojan Smojver <bo...@rexursive.com> on 2007/03/22 03:15:21 UTC
apr_file_gets()/apr_file_read() locking problem
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.
Did anyone see this?
--
Bojan
Re: apr_file_gets()/apr_file_read() locking problem
Posted by Bojan Smojver <bo...@rexursive.com>.
On Thu, 2007-03-22 at 16:42 +0000, Joe Orton wrote:
> 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).
This passed the compilation and make test.
--
Bojan
Re: apr_file_gets()/apr_file_read() locking problem
Posted by Joe Orton <jo...@redhat.com>.
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
Re: apr_file_gets()/apr_file_read() locking problem
Posted by Bojan Smojver <bo...@rexursive.com>.
On Thu, 2007-03-22 at 13:24 +1100, Bojan Smojver wrote:
> It happened because I passed in (incorrectly) APR_OS_DEFAULT instead of
> zero. Nevertheless, I think we may still have a problem with this
> locking business.
Yep, definitely locks up with these flags specified to
apr_file_mktemp():
APR_CREATE | APR_READ | APR_WRITE | APR_EXCL | APR_DELONCLOSE |
APR_XTHREAD | APR_BUFFERED
--
Bojan
Re: apr_file_gets()/apr_file_read() locking problem
Posted by Bojan Smojver <bo...@rexursive.com>.
On Thu, 2007-03-22 at 13:15 +1100, Bojan Smojver wrote:
> not sure why, but that's what happened on FC6
It happened because I passed in (incorrectly) APR_OS_DEFAULT instead of
zero. Nevertheless, I think we may still have a problem with this
locking business.
--
Bojan