This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: pthread_rwlock_tryrdlock bug (with test & patch)
- From: Christopher Faylor <cgf-use-the-mailinglist-please at cygwin dot com>
- To: cygwin at cygwin dot com
- Date: Mon, 7 Jan 2013 01:43:17 -0500
- Subject: Re: pthread_rwlock_tryrdlock bug (with test & patch)
- References: <50E9B35F.7030307@iki.fi>
- Reply-to: cygwin at cygwin dot com
On Sun, Jan 06, 2013 at 06:24:47PM +0100, Antti Kantee wrote:
>[I'd submit this to cygwin-patches, but the web page says only
>subscribers can post to that list, so please bear with me for this
>simple issue]
>
>Hi,
>
>Calling pthread_rwlock_tryrdlock() twice from the same thread always
>fails with EBUSY the second time. See attached test.c. Replacing the
>second tryrdlock() with rdlock() makes the call succeed, leading me to
>believe there is a bug in tryrdlock().
>
>Assuming I was looking at the correct source file, the attached patch
>should fix the issue. I'm not sure why the lookup_reader() call was
>there in the first place; perhaps a remnant from a time when recursive
>read locking was not supported?
>
>While looking at tryrdlock(), the handling of ULONG_MAX also seems
>wrong, as you'd probably want to return EAGAIN instead of allocating
>another reader structure. However, that problem is arguably more of an
>academic issue and therefore I didn't touch it in my patch.
Thanks for the analysis and patch. I've made a few more changes to this
function and should have everything checked in tomorrow.
cgf
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple