The mtx_init() and sx_init() functions bzero'd locks before handing them

off to witness_init() making the check for double intializating a lock by
testing the LO_INITIALIZED flag moot.  Workaround this by checking the
LO_INITIALIZED flag ourself before we bzero the lock structure.
This commit is contained in:
John Baldwin 2001-10-20 01:22:42 +00:00
parent c932615213
commit 7ada587697
3 changed files with 9 additions and 3 deletions

View File

@ -670,8 +670,10 @@ mtx_init(struct mtx *m, const char *description, int opts)
mtx_validate(m);
#endif
bzero(m, sizeof(*m));
lock = &m->mtx_object;
KASSERT((lock->lo_flags & LO_INITIALIZED) == 0,
("mutex %s %p already initialized", description, m));
bzero(m, sizeof(*m));
if (opts & MTX_SPIN)
lock->lo_class = &lock_class_mtx_spin;
else

View File

@ -53,8 +53,10 @@ sx_init(struct sx *sx, const char *description)
{
struct lock_object *lock;
bzero(sx, sizeof(*sx));
lock = &sx->sx_object;
KASSERT((lock->lo_flags & LO_INITIALIZED) == 0,
("sx lock %s %p already initialized", description, sx));
bzero(sx, sizeof(*sx));
lock->lo_class = &lock_class_sx;
lock->lo_name = description;
lock->lo_flags = LO_WITNESS | LO_RECURSABLE | LO_SLEEPABLE |

View File

@ -670,8 +670,10 @@ mtx_init(struct mtx *m, const char *description, int opts)
mtx_validate(m);
#endif
bzero(m, sizeof(*m));
lock = &m->mtx_object;
KASSERT((lock->lo_flags & LO_INITIALIZED) == 0,
("mutex %s %p already initialized", description, m));
bzero(m, sizeof(*m));
if (opts & MTX_SPIN)
lock->lo_class = &lock_class_mtx_spin;
else