refcount locks to avoid deadlocks; array threadsafety should be good to go now

SVN revision: 50962
This commit is contained in:
Mike Blumenkrantz 2010-08-10 12:14:59 +00:00
parent c09c5ed690
commit a7398f4e08
1 changed files with 14 additions and 10 deletions

View File

@ -107,12 +107,14 @@ eina_array_rdlock(Eina_Array *array)
if (!array) return EINA_FALSE;
if (array->threadsafe)
{
int ret;
if (!array->lockcount++)
{
int ret;
ret = pthread_rwlock_rdlock(&array->lock);
if ((ret != 0) && (ret != EDEADLK))
return EINA_FALSE;
array->lockcount++;
ret = pthread_rwlock_rdlock(&array->lock);
if ((ret != 0) && (ret != EDEADLK))
return EINA_FALSE;
}
}
return EINA_TRUE;
}
@ -123,12 +125,14 @@ eina_array_wrlock(Eina_Array *array)
if (!array) return EINA_FALSE;
if (array->threadsafe)
{
int ret;
if (!array->lockcount++)
{
int ret;
ret = pthread_rwlock_wrlock(&array->lock);
if ((ret != 0) && (ret != EDEADLK))
return EINA_FALSE;
array->lockcount++;
ret = pthread_rwlock_wrlock(&array->lock);
if ((ret != 0) && (ret != EDEADLK))
return EINA_FALSE;
}
}
return EINA_TRUE;
}