[Date Prev][Date Next] [Chronological] [Thread] [Top]

rdwr code looks wrong to me (ITS#395)



Full_Name: Ty Sarna
Version: 1.2.7
OS: IRIX 6.5
URL: ftp://ftp.openldap.org/incoming/tsarna-rwdr-120899.diff
Submission from: (NULL) (207.158.192.37)


Hi. I was adding some new code to 1.2.7 which used rdwr locks, and noticed some
strange behavior. When I tracked down the problems withmy new code, I
discovered
that it seemed to be getting a reader lock while a writer lock was held.

So I looked at rdwr.c, and the logic seems... wrong. Perhaps I'm
misunderstanding,
but shouldn't the tests for "rw->ltrw_w_active > 1" be "> 0"? There should never
be
more than one writer active anyway. This change seems to have been made when the
old
implementation was replaced with one from a different textbook. Based on the
tags,
every 1.2 and later version has this change.

When I changed these tests to look the way I think they should, my code started
working as expected.

If I'm right about this being incorrect, I wonder what else is losing as a
result
of this?