revert the recent "use trylock to hide locking errors" changes

and their associated changes, in particular, the following versions.
	prop_array.c		1.13-1.16
	prop_dictionary.c	1.25-1.28
	prop_object_impl.h	1.21-1.25
ok'ed by core@.
This commit is contained in:
yamt 2008-05-24 14:24:04 +00:00
parent 9b5a328100
commit 6787eedebd
3 changed files with 45 additions and 75 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: prop_array.c,v 1.16 2008/05/07 10:16:41 tron Exp $ */
/* $NetBSD: prop_array.c,v 1.17 2008/05/24 14:24:04 yamt Exp $ */
/*-
* Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
@ -312,11 +312,10 @@ _prop_array_iterator_next_object(void *v)
struct _prop_array_iterator *pai = v;
prop_array_t pa = pai->pai_base.pi_obj;
prop_object_t po = NULL;
bool acquired;
_PROP_ASSERT(prop_object_is_array(pa));
acquired = _PROP_RWLOCK_TRYRDLOCK(pa->pa_rwlock);
_PROP_RWLOCK_OWNED(pa->pa_rwlock);
_PROP_RWLOCK_RDLOCK(pa->pa_rwlock);
if (pa->pa_version != pai->pai_base.pi_version)
goto out; /* array changed during iteration */
@ -330,9 +329,7 @@ _prop_array_iterator_next_object(void *v)
pai->pai_index++;
out:
if (acquired) {
_PROP_RWLOCK_UNLOCK(pa->pa_rwlock);
}
return (po);
}
@ -341,18 +338,15 @@ _prop_array_iterator_reset(void *v)
{
struct _prop_array_iterator *pai = v;
prop_array_t pa = pai->pai_base.pi_obj;
bool acquired;
_PROP_ASSERT(prop_object_is_array(pa));
acquired = _PROP_RWLOCK_TRYRDLOCK(pa->pa_rwlock);
_PROP_RWLOCK_OWNED(pa->pa_rwlock);
_PROP_RWLOCK_RDLOCK(pa->pa_rwlock);
pai->pai_index = 0;
pai->pai_base.pi_version = pa->pa_version;
if (acquired) {
_PROP_RWLOCK_UNLOCK(pa->pa_rwlock);
}
}
/*
@ -508,9 +502,7 @@ prop_array_iterator(prop_array_t pa)
pai->pai_base.pi_reset = _prop_array_iterator_reset;
prop_object_retain(pa);
pai->pai_base.pi_obj = pa;
_PROP_RWLOCK_RDLOCK(pa->pa_rwlock);
_prop_array_iterator_reset(pai);
_PROP_RWLOCK_UNLOCK(pa->pa_rwlock);
return (&pai->pai_base);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: prop_dictionary.c,v 1.28 2008/05/07 10:16:41 tron Exp $ */
/* $NetBSD: prop_dictionary.c,v 1.29 2008/05/24 14:24:04 yamt Exp $ */
/*-
* Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
@ -399,7 +399,6 @@ _prop_dictionary_externalize(struct _prop_object_externalize_context *ctx,
bool rv = false;
_PROP_RWLOCK_RDLOCK(pd->pd_rwlock);
_PROP_RWLOCK_OWNED(pd->pd_rwlock);
if (pd->pd_count == 0) {
_PROP_RWLOCK_UNLOCK(pd->pd_rwlock);
@ -571,11 +570,10 @@ _prop_dictionary_iterator_next_object(void *v)
struct _prop_dictionary_iterator *pdi = v;
prop_dictionary_t pd = pdi->pdi_base.pi_obj;
prop_dictionary_keysym_t pdk = NULL;
bool acquired;
_PROP_ASSERT(prop_object_is_dictionary(pd));
acquired = _PROP_RWLOCK_TRYRDLOCK(pd->pd_rwlock);
_PROP_RWLOCK_OWNED(pd->pd_rwlock);
_PROP_RWLOCK_RDLOCK(pd->pd_rwlock);
if (pd->pd_version != pdi->pdi_base.pi_version)
goto out; /* dictionary changed during iteration */
@ -589,9 +587,7 @@ _prop_dictionary_iterator_next_object(void *v)
pdi->pdi_index++;
out:
if (acquired) {
_PROP_RWLOCK_UNLOCK(pd->pd_rwlock);
}
return (pdk);
}
@ -600,18 +596,15 @@ _prop_dictionary_iterator_reset(void *v)
{
struct _prop_dictionary_iterator *pdi = v;
prop_dictionary_t pd = pdi->pdi_base.pi_obj;
bool acquired;
_PROP_ASSERT(prop_object_is_dictionary(pd));
acquired = _PROP_RWLOCK_TRYRDLOCK(pd->pd_rwlock);
_PROP_RWLOCK_OWNED(pd->pd_rwlock);
_PROP_RWLOCK_RDLOCK(pd->pd_rwlock);
pdi->pdi_index = 0;
pdi->pdi_base.pi_version = pd->pd_version;
if (acquired) {
_PROP_RWLOCK_UNLOCK(pd->pd_rwlock);
}
}
/*
@ -771,9 +764,7 @@ prop_dictionary_iterator(prop_dictionary_t pd)
pdi->pdi_base.pi_reset = _prop_dictionary_iterator_reset;
prop_object_retain(pd);
pdi->pdi_base.pi_obj = pd;
_PROP_RWLOCK_RDLOCK(pd->pd_rwlock);
_prop_dictionary_iterator_reset(pdi);
_PROP_RWLOCK_UNLOCK(pd->pd_rwlock);
return (&pdi->pdi_base);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: prop_object_impl.h,v 1.25 2008/05/07 10:16:41 tron Exp $ */
/* $NetBSD: prop_object_impl.h,v 1.26 2008/05/24 14:24:04 yamt Exp $ */
/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
@ -265,8 +265,6 @@ struct _prop_object_iterator {
#define _PROP_RWLOCK_WRLOCK(x) rw_enter(&(x), RW_WRITER)
#define _PROP_RWLOCK_UNLOCK(x) rw_exit(&(x))
#define _PROP_RWLOCK_DESTROY(x) rw_destroy(&(x))
#define _PROP_RWLOCK_OWNED(x) _PROP_ASSERT(rw_lock_held(&(x)))
#define _PROP_RWLOCK_TRYRDLOCK(x) rw_tryenter(&(x), RW_READER)
#elif defined(_STANDALONE)
@ -303,8 +301,6 @@ void * _prop_standalone_realloc(void *, size_t);
#define _PROP_RWLOCK_WRLOCK(x) /* nothing */
#define _PROP_RWLOCK_UNLOCK(x) /* nothing */
#define _PROP_RWLOCK_DESTROY(x) /* nothing */
#define _PROP_RWLOCK_OWNED(x) /* nothing */
#define _PROP_RWLOCK_TRYRDLOCK(x) 0
#else
@ -348,9 +344,6 @@ void * _prop_standalone_realloc(void *, size_t);
#define _PROP_RWLOCK_WRLOCK(x) rwlock_wrlock(&(x))
#define _PROP_RWLOCK_UNLOCK(x) rwlock_unlock(&(x))
#define _PROP_RWLOCK_DESTROY(x) rwlock_destroy(&(x))
#define _PROP_RWLOCK_OWNED(x) /* nothing */
#define _PROP_RWLOCK_TRYRDLOCK(x) rwlock_tryrdlock(&(x))
#elif defined(HAVE_NBTOOL_CONFIG_H)
/*
* None of NetBSD's build tools are multi-threaded.
@ -365,9 +358,6 @@ void * _prop_standalone_realloc(void *, size_t);
#define _PROP_RWLOCK_WRLOCK(x) /* nothing */
#define _PROP_RWLOCK_UNLOCK(x) /* nothing */
#define _PROP_RWLOCK_DESTROY(x) /* nothing */
#define _PROP_RWLOCK_OWNED(x) /* nothing */
#define _PROP_RWLOCK_TRYRDLOCK(x) 0
#else
/*
* Use pthread mutexes everywhere else.
@ -384,9 +374,6 @@ void * _prop_standalone_realloc(void *, size_t);
#define _PROP_RWLOCK_WRLOCK(x) pthread_rwlock_wrlock(&(x))
#define _PROP_RWLOCK_UNLOCK(x) pthread_rwlock_unlock(&(x))
#define _PROP_RWLOCK_DESTROY(x) pthread_rwlock_destroy(&(x))
#define _PROP_RWLOCK_OWNED(x) /* nothing */
#define _PROP_RWLOCK_TRYRDLOCK(x) pthread_rwlock_tryrdlock(x)
#endif
#endif /* _KERNEL */