This is the mail archive of the
cygwin
mailing list for the Cygwin project.
pthread_rwlock_tryrdlock bug (with test & patch)
- From: Antti Kantee <pooka at iki dot fi>
- To: cygwin at cygwin dot com
- Date: Sun, 06 Jan 2013 18:24:47 +0100
- Subject: pthread_rwlock_tryrdlock bug (with test & patch)
[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.
- antti
p.s. please cc me on any responses
Attachment:
test.c
Description: Text document
Attachment:
tryrdlock.patch
Description: Text document
--
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