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:
parent
9b5a328100
commit
6787eedebd
|
@ -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.
|
* 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;
|
struct _prop_array_iterator *pai = v;
|
||||||
prop_array_t pa = pai->pai_base.pi_obj;
|
prop_array_t pa = pai->pai_base.pi_obj;
|
||||||
prop_object_t po = NULL;
|
prop_object_t po = NULL;
|
||||||
bool acquired;
|
|
||||||
|
|
||||||
_PROP_ASSERT(prop_object_is_array(pa));
|
_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)
|
if (pa->pa_version != pai->pai_base.pi_version)
|
||||||
goto out; /* array changed during iteration */
|
goto out; /* array changed during iteration */
|
||||||
|
@ -330,9 +329,7 @@ _prop_array_iterator_next_object(void *v)
|
||||||
pai->pai_index++;
|
pai->pai_index++;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (acquired) {
|
_PROP_RWLOCK_UNLOCK(pa->pa_rwlock);
|
||||||
_PROP_RWLOCK_UNLOCK(pa->pa_rwlock);
|
|
||||||
}
|
|
||||||
return (po);
|
return (po);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -341,18 +338,15 @@ _prop_array_iterator_reset(void *v)
|
||||||
{
|
{
|
||||||
struct _prop_array_iterator *pai = v;
|
struct _prop_array_iterator *pai = v;
|
||||||
prop_array_t pa = pai->pai_base.pi_obj;
|
prop_array_t pa = pai->pai_base.pi_obj;
|
||||||
bool acquired;
|
|
||||||
|
|
||||||
_PROP_ASSERT(prop_object_is_array(pa));
|
_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_index = 0;
|
||||||
pai->pai_base.pi_version = pa->pa_version;
|
pai->pai_base.pi_version = pa->pa_version;
|
||||||
|
|
||||||
if (acquired) {
|
_PROP_RWLOCK_UNLOCK(pa->pa_rwlock);
|
||||||
_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;
|
pai->pai_base.pi_reset = _prop_array_iterator_reset;
|
||||||
prop_object_retain(pa);
|
prop_object_retain(pa);
|
||||||
pai->pai_base.pi_obj = pa;
|
pai->pai_base.pi_obj = pa;
|
||||||
_PROP_RWLOCK_RDLOCK(pa->pa_rwlock);
|
|
||||||
_prop_array_iterator_reset(pai);
|
_prop_array_iterator_reset(pai);
|
||||||
_PROP_RWLOCK_UNLOCK(pa->pa_rwlock);
|
|
||||||
|
|
||||||
return (&pai->pai_base);
|
return (&pai->pai_base);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.
|
* Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
|
||||||
|
@ -399,7 +399,6 @@ _prop_dictionary_externalize(struct _prop_object_externalize_context *ctx,
|
||||||
bool rv = false;
|
bool rv = false;
|
||||||
|
|
||||||
_PROP_RWLOCK_RDLOCK(pd->pd_rwlock);
|
_PROP_RWLOCK_RDLOCK(pd->pd_rwlock);
|
||||||
_PROP_RWLOCK_OWNED(pd->pd_rwlock);
|
|
||||||
|
|
||||||
if (pd->pd_count == 0) {
|
if (pd->pd_count == 0) {
|
||||||
_PROP_RWLOCK_UNLOCK(pd->pd_rwlock);
|
_PROP_RWLOCK_UNLOCK(pd->pd_rwlock);
|
||||||
|
@ -571,11 +570,10 @@ _prop_dictionary_iterator_next_object(void *v)
|
||||||
struct _prop_dictionary_iterator *pdi = v;
|
struct _prop_dictionary_iterator *pdi = v;
|
||||||
prop_dictionary_t pd = pdi->pdi_base.pi_obj;
|
prop_dictionary_t pd = pdi->pdi_base.pi_obj;
|
||||||
prop_dictionary_keysym_t pdk = NULL;
|
prop_dictionary_keysym_t pdk = NULL;
|
||||||
bool acquired;
|
|
||||||
|
|
||||||
_PROP_ASSERT(prop_object_is_dictionary(pd));
|
_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)
|
if (pd->pd_version != pdi->pdi_base.pi_version)
|
||||||
goto out; /* dictionary changed during iteration */
|
goto out; /* dictionary changed during iteration */
|
||||||
|
@ -589,9 +587,7 @@ _prop_dictionary_iterator_next_object(void *v)
|
||||||
pdi->pdi_index++;
|
pdi->pdi_index++;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (acquired) {
|
_PROP_RWLOCK_UNLOCK(pd->pd_rwlock);
|
||||||
_PROP_RWLOCK_UNLOCK(pd->pd_rwlock);
|
|
||||||
}
|
|
||||||
return (pdk);
|
return (pdk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -600,18 +596,15 @@ _prop_dictionary_iterator_reset(void *v)
|
||||||
{
|
{
|
||||||
struct _prop_dictionary_iterator *pdi = v;
|
struct _prop_dictionary_iterator *pdi = v;
|
||||||
prop_dictionary_t pd = pdi->pdi_base.pi_obj;
|
prop_dictionary_t pd = pdi->pdi_base.pi_obj;
|
||||||
bool acquired;
|
|
||||||
|
|
||||||
_PROP_ASSERT(prop_object_is_dictionary(pd));
|
_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_index = 0;
|
||||||
pdi->pdi_base.pi_version = pd->pd_version;
|
pdi->pdi_base.pi_version = pd->pd_version;
|
||||||
|
|
||||||
if (acquired) {
|
_PROP_RWLOCK_UNLOCK(pd->pd_rwlock);
|
||||||
_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;
|
pdi->pdi_base.pi_reset = _prop_dictionary_iterator_reset;
|
||||||
prop_object_retain(pd);
|
prop_object_retain(pd);
|
||||||
pdi->pdi_base.pi_obj = pd;
|
pdi->pdi_base.pi_obj = pd;
|
||||||
_PROP_RWLOCK_RDLOCK(pd->pd_rwlock);
|
|
||||||
_prop_dictionary_iterator_reset(pdi);
|
_prop_dictionary_iterator_reset(pdi);
|
||||||
_PROP_RWLOCK_UNLOCK(pd->pd_rwlock);
|
|
||||||
|
|
||||||
return (&pdi->pdi_base);
|
return (&pdi->pdi_base);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.
|
* Copyright (c) 2006 The NetBSD Foundation, Inc.
|
||||||
|
@ -259,14 +259,12 @@ struct _prop_object_iterator {
|
||||||
#define _PROP_MUTEX_LOCK(x) simple_lock(&(x))
|
#define _PROP_MUTEX_LOCK(x) simple_lock(&(x))
|
||||||
#define _PROP_MUTEX_UNLOCK(x) simple_unlock(&(x))
|
#define _PROP_MUTEX_UNLOCK(x) simple_unlock(&(x))
|
||||||
|
|
||||||
#define _PROP_RWLOCK_DECL(x) krwlock_t x ;
|
#define _PROP_RWLOCK_DECL(x) krwlock_t x ;
|
||||||
#define _PROP_RWLOCK_INIT(x) rw_init(&(x))
|
#define _PROP_RWLOCK_INIT(x) rw_init(&(x))
|
||||||
#define _PROP_RWLOCK_RDLOCK(x) rw_enter(&(x), RW_READER)
|
#define _PROP_RWLOCK_RDLOCK(x) rw_enter(&(x), RW_READER)
|
||||||
#define _PROP_RWLOCK_WRLOCK(x) rw_enter(&(x), RW_WRITER)
|
#define _PROP_RWLOCK_WRLOCK(x) rw_enter(&(x), RW_WRITER)
|
||||||
#define _PROP_RWLOCK_UNLOCK(x) rw_exit(&(x))
|
#define _PROP_RWLOCK_UNLOCK(x) rw_exit(&(x))
|
||||||
#define _PROP_RWLOCK_DESTROY(x) rw_destroy(&(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)
|
#elif defined(_STANDALONE)
|
||||||
|
|
||||||
|
@ -297,14 +295,12 @@ void * _prop_standalone_realloc(void *, size_t);
|
||||||
#define _PROP_MUTEX_LOCK(x) /* nothing */
|
#define _PROP_MUTEX_LOCK(x) /* nothing */
|
||||||
#define _PROP_MUTEX_UNLOCK(x) /* nothing */
|
#define _PROP_MUTEX_UNLOCK(x) /* nothing */
|
||||||
|
|
||||||
#define _PROP_RWLOCK_DECL(x) /* nothing */
|
#define _PROP_RWLOCK_DECL(x) /* nothing */
|
||||||
#define _PROP_RWLOCK_INIT(x) /* nothing */
|
#define _PROP_RWLOCK_INIT(x) /* nothing */
|
||||||
#define _PROP_RWLOCK_RDLOCK(x) /* nothing */
|
#define _PROP_RWLOCK_RDLOCK(x) /* nothing */
|
||||||
#define _PROP_RWLOCK_WRLOCK(x) /* nothing */
|
#define _PROP_RWLOCK_WRLOCK(x) /* nothing */
|
||||||
#define _PROP_RWLOCK_UNLOCK(x) /* nothing */
|
#define _PROP_RWLOCK_UNLOCK(x) /* nothing */
|
||||||
#define _PROP_RWLOCK_DESTROY(x) /* nothing */
|
#define _PROP_RWLOCK_DESTROY(x) /* nothing */
|
||||||
#define _PROP_RWLOCK_OWNED(x) /* nothing */
|
|
||||||
#define _PROP_RWLOCK_TRYRDLOCK(x) 0
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
@ -342,15 +338,12 @@ void * _prop_standalone_realloc(void *, size_t);
|
||||||
#define _PROP_MUTEX_LOCK(x) mutex_lock(&(x))
|
#define _PROP_MUTEX_LOCK(x) mutex_lock(&(x))
|
||||||
#define _PROP_MUTEX_UNLOCK(x) mutex_unlock(&(x))
|
#define _PROP_MUTEX_UNLOCK(x) mutex_unlock(&(x))
|
||||||
|
|
||||||
#define _PROP_RWLOCK_DECL(x) rwlock_t x ;
|
#define _PROP_RWLOCK_DECL(x) rwlock_t x ;
|
||||||
#define _PROP_RWLOCK_INIT(x) rwlock_init(&(x), NULL)
|
#define _PROP_RWLOCK_INIT(x) rwlock_init(&(x), NULL)
|
||||||
#define _PROP_RWLOCK_RDLOCK(x) rwlock_rdlock(&(x))
|
#define _PROP_RWLOCK_RDLOCK(x) rwlock_rdlock(&(x))
|
||||||
#define _PROP_RWLOCK_WRLOCK(x) rwlock_wrlock(&(x))
|
#define _PROP_RWLOCK_WRLOCK(x) rwlock_wrlock(&(x))
|
||||||
#define _PROP_RWLOCK_UNLOCK(x) rwlock_unlock(&(x))
|
#define _PROP_RWLOCK_UNLOCK(x) rwlock_unlock(&(x))
|
||||||
#define _PROP_RWLOCK_DESTROY(x) rwlock_destroy(&(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)
|
#elif defined(HAVE_NBTOOL_CONFIG_H)
|
||||||
/*
|
/*
|
||||||
* None of NetBSD's build tools are multi-threaded.
|
* None of NetBSD's build tools are multi-threaded.
|
||||||
|
@ -359,15 +352,12 @@ void * _prop_standalone_realloc(void *, size_t);
|
||||||
#define _PROP_MUTEX_LOCK(x) /* nothing */
|
#define _PROP_MUTEX_LOCK(x) /* nothing */
|
||||||
#define _PROP_MUTEX_UNLOCK(x) /* nothing */
|
#define _PROP_MUTEX_UNLOCK(x) /* nothing */
|
||||||
|
|
||||||
#define _PROP_RWLOCK_DECL(x) /* nothing */
|
#define _PROP_RWLOCK_DECL(x) /* nothing */
|
||||||
#define _PROP_RWLOCK_INIT(x) /* nothing */
|
#define _PROP_RWLOCK_INIT(x) /* nothing */
|
||||||
#define _PROP_RWLOCK_RDLOCK(x) /* nothing */
|
#define _PROP_RWLOCK_RDLOCK(x) /* nothing */
|
||||||
#define _PROP_RWLOCK_WRLOCK(x) /* nothing */
|
#define _PROP_RWLOCK_WRLOCK(x) /* nothing */
|
||||||
#define _PROP_RWLOCK_UNLOCK(x) /* nothing */
|
#define _PROP_RWLOCK_UNLOCK(x) /* nothing */
|
||||||
#define _PROP_RWLOCK_DESTROY(x) /* nothing */
|
#define _PROP_RWLOCK_DESTROY(x) /* nothing */
|
||||||
#define _PROP_RWLOCK_OWNED(x) /* nothing */
|
|
||||||
#define _PROP_RWLOCK_TRYRDLOCK(x) 0
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
/*
|
/*
|
||||||
* Use pthread mutexes everywhere else.
|
* Use pthread mutexes everywhere else.
|
||||||
|
@ -378,15 +368,12 @@ void * _prop_standalone_realloc(void *, size_t);
|
||||||
#define _PROP_MUTEX_LOCK(x) pthread_mutex_lock(&(x))
|
#define _PROP_MUTEX_LOCK(x) pthread_mutex_lock(&(x))
|
||||||
#define _PROP_MUTEX_UNLOCK(x) pthread_mutex_unlock(&(x))
|
#define _PROP_MUTEX_UNLOCK(x) pthread_mutex_unlock(&(x))
|
||||||
|
|
||||||
#define _PROP_RWLOCK_DECL(x) pthread_rwlock_t x ;
|
#define _PROP_RWLOCK_DECL(x) pthread_rwlock_t x ;
|
||||||
#define _PROP_RWLOCK_INIT(x) pthread_rwlock_init(&(x), NULL)
|
#define _PROP_RWLOCK_INIT(x) pthread_rwlock_init(&(x), NULL)
|
||||||
#define _PROP_RWLOCK_RDLOCK(x) pthread_rwlock_rdlock(&(x))
|
#define _PROP_RWLOCK_RDLOCK(x) pthread_rwlock_rdlock(&(x))
|
||||||
#define _PROP_RWLOCK_WRLOCK(x) pthread_rwlock_wrlock(&(x))
|
#define _PROP_RWLOCK_WRLOCK(x) pthread_rwlock_wrlock(&(x))
|
||||||
#define _PROP_RWLOCK_UNLOCK(x) pthread_rwlock_unlock(&(x))
|
#define _PROP_RWLOCK_UNLOCK(x) pthread_rwlock_unlock(&(x))
|
||||||
#define _PROP_RWLOCK_DESTROY(x) pthread_rwlock_destroy(&(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
|
||||||
|
|
||||||
#endif /* _KERNEL */
|
#endif /* _KERNEL */
|
||||||
|
|
Loading…
Reference in New Issue