diff options
author | rooneg <rooneg@13f79535-47bb-0310-9956-ffa450edef68> | 2006-01-26 21:43:50 +0000 |
---|---|---|
committer | rooneg <rooneg@13f79535-47bb-0310-9956-ffa450edef68> | 2006-01-26 21:43:50 +0000 |
commit | dd70cf1ab46a0311247c5617c4937bd1c63cf762 (patch) | |
tree | 7d9773a0e65e5a2eeacd3dcf68e8c60b68f80f13 | |
parent | 54f9f6d5042c03b56f5b878956343c83b37e9974 (diff) | |
download | libapr-dd70cf1ab46a0311247c5617c4937bd1c63cf762.tar.gz |
Merge r371172 to 0.9.x.
Original log message:
Fix an assert that occurs when you destroy a rwlock on win32 and later clear
the pool it was allocated from.
Submitted by: Evgueni Brevnov <evgueni.brevnov gmail.com>
* locks/win32/thread_rwlock.c
(apr_thread_rwlock_destroy): Use apr_pool_cleanup_run to call our cleanup
function.
(thread_rwlock_cleanup): Put the destruction of the rwlock here instead
of in the destructor function.
* test/testlock.c
(test_thread_rwlocks): Destroy the rwlock explicitly so we can see this
kind of problem.
* CHANGES: Note change.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/0.9.x@372615 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | CHANGES | 3 | ||||
-rw-r--r-- | locks/win32/thread_rwlock.c | 18 | ||||
-rw-r--r-- | test/testlock.c | 2 |
3 files changed, 15 insertions, 8 deletions
@@ -2,6 +2,9 @@ Changes with APR 0.9.8-dev *) Keep testpipe.c from hanging on win32. [Garrett Rooney] + *) Fix assertion from double close of a handle with a rwlock on win32. + [Evgueni Brevnov <evgueni.brevnov gmail.com>] + *) Documented that apr_stat and apr_dir_read can return APR_INCOMPLETE, and how to determine which parts of the resulting apr_finfo_t can be used in such a case. diff --git a/locks/win32/thread_rwlock.c b/locks/win32/thread_rwlock.c index 75d79bcbe..9207d7929 100644 --- a/locks/win32/thread_rwlock.c +++ b/locks/win32/thread_rwlock.c @@ -23,7 +23,15 @@ static apr_status_t thread_rwlock_cleanup(void *data) { - return apr_thread_rwlock_destroy((apr_thread_rwlock_t *) data); + apr_thread_rwlock_t *rwlock = data; + + if (! CloseHandle(rwlock->read_event)) + return apr_get_os_error(); + + if (! CloseHandle(rwlock->write_mutex)) + return apr_get_os_error(); + + return APR_SUCCESS; } APR_DECLARE(apr_status_t)apr_thread_rwlock_create(apr_thread_rwlock_t **rwlock, @@ -151,13 +159,7 @@ 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) { - if (! CloseHandle(rwlock->read_event)) - return apr_get_os_error(); - - if (! CloseHandle(rwlock->write_mutex)) - return apr_get_os_error(); - - return APR_SUCCESS; + return apr_pool_cleanup_run(rwlock->pool, rwlock, thread_rwlock_cleanup); } APR_POOL_IMPLEMENT_ACCESSOR(thread_rwlock) diff --git a/test/testlock.c b/test/testlock.c index 3ede9c7e5..562008d6b 100644 --- a/test/testlock.c +++ b/test/testlock.c @@ -205,6 +205,8 @@ static void test_thread_rwlock(CuTest *tc) apr_thread_join(&s4, t4); CuAssertIntEquals(tc, MAX_ITER, x); + + apr_thread_rwlock_destroy(rwlock); } static void test_cond(CuTest *tc) |