diff options
author | jorton <jorton@13f79535-47bb-0310-9956-ffa450edef68> | 2003-10-03 15:14:38 +0000 |
---|---|---|
committer | jorton <jorton@13f79535-47bb-0310-9956-ffa450edef68> | 2003-10-03 15:14:38 +0000 |
commit | 21e630b74ab4225a94484f6dbc32be11850737bf (patch) | |
tree | 0a17fdf2e94a29d0d31ea41568264febcc742d7d /locks | |
parent | dafb6e7f406e0f8156f3b7b11993940de9d2ed99 (diff) | |
download | libapr-21e630b74ab4225a94484f6dbc32be11850737bf.tar.gz |
To produce results which are defined by POSIX, at time of cleanup the
rwlock must be initialized but not locked by any thread. Accordingly,
remove code which POSIX says gives undefined results:
* locks/unix/thread_rwlock.c (thread_rwlock_cleanup): Don't unlock an
unlocked lock. (apr_thread_rwlock_create): Don't destroy an
uninitialized lock if _init fails. (apr_thread_rwlock_destroy): If
cleanup fails, the lock must be in a bad state, so don't run cleanup
again.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@64679 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'locks')
-rw-r--r-- | locks/unix/thread_rwlock.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/locks/unix/thread_rwlock.c b/locks/unix/thread_rwlock.c index acbfceb50..056f58721 100644 --- a/locks/unix/thread_rwlock.c +++ b/locks/unix/thread_rwlock.c @@ -59,12 +59,13 @@ #ifdef HAVE_PTHREAD_RWLOCK_INIT +/* The rwlock must be initialized but not locked by any thread when + * cleanup is called. */ static apr_status_t thread_rwlock_cleanup(void *data) { apr_thread_rwlock_t *rwlock = (apr_thread_rwlock_t *)data; apr_status_t stat; - pthread_rwlock_unlock(rwlock->rwlock); stat = pthread_rwlock_destroy(rwlock->rwlock); #ifdef PTHREAD_SETS_ERRNO if (stat) { @@ -99,7 +100,6 @@ APR_DECLARE(apr_status_t) apr_thread_rwlock_create(apr_thread_rwlock_t **rwlock, #ifdef PTHREAD_SETS_ERRNO stat = errno; #endif - thread_rwlock_cleanup(new_rwlock); return stat; } @@ -184,11 +184,8 @@ APR_DECLARE(apr_status_t) apr_thread_rwlock_unlock(apr_thread_rwlock_t *rwlock) APR_DECLARE(apr_status_t) apr_thread_rwlock_destroy(apr_thread_rwlock_t *rwlock) { - apr_status_t stat; - if ((stat = thread_rwlock_cleanup(rwlock)) == APR_SUCCESS) { - apr_pool_cleanup_kill(rwlock->pool, rwlock, thread_rwlock_cleanup); - return APR_SUCCESS; - } + apr_status_t stat = thread_rwlock_cleanup(rwlock); + apr_pool_cleanup_kill(rwlock->pool, rwlock, thread_rwlock_cleanup); return stat; } |