You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by ro...@apache.org on 2006/01/22 03:45:20 UTC
svn commit: r371172 - in /apr/apr/trunk: CHANGES locks/win32/thread_rwlock.c
test/testlock.c
Author: rooneg
Date: Sat Jan 21 18:45:18 2006
New Revision: 371172
URL: http://svn.apache.org/viewcvs?rev=371172&view=rev
Log:
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.
Modified:
apr/apr/trunk/CHANGES
apr/apr/trunk/locks/win32/thread_rwlock.c
apr/apr/trunk/test/testlock.c
Modified: apr/apr/trunk/CHANGES
URL: http://svn.apache.org/viewcvs/apr/apr/trunk/CHANGES?rev=371172&r1=371171&r2=371172&view=diff
==============================================================================
--- apr/apr/trunk/CHANGES (original)
+++ apr/apr/trunk/CHANGES Sat Jan 21 18:45:18 2006
@@ -1,5 +1,8 @@
Changes for APR 1.3.0
+ *) Fix assertion from double close of a handle with a rwlock on win32.
+ [Evgueni Brevnov <evgueni.brevnov gmail.com>]
+
*) APR_FIND_APR macro now supports customisable detailed checks on
each installed apr. [Justin Erenkrantz, Colm MacCarthaigh]
Modified: apr/apr/trunk/locks/win32/thread_rwlock.c
URL: http://svn.apache.org/viewcvs/apr/apr/trunk/locks/win32/thread_rwlock.c?rev=371172&r1=371171&r2=371172&view=diff
==============================================================================
--- apr/apr/trunk/locks/win32/thread_rwlock.c (original)
+++ apr/apr/trunk/locks/win32/thread_rwlock.c Sat Jan 21 18:45:18 2006
@@ -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_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)
Modified: apr/apr/trunk/test/testlock.c
URL: http://svn.apache.org/viewcvs/apr/apr/trunk/test/testlock.c?rev=371172&r1=371171&r2=371172&view=diff
==============================================================================
--- apr/apr/trunk/test/testlock.c (original)
+++ apr/apr/trunk/test/testlock.c Sat Jan 21 18:45:18 2006
@@ -209,6 +209,8 @@
apr_thread_join(&s4, t4);
ABTS_INT_EQUAL(tc, MAX_ITER, x);
+
+ apr_thread_rwlock_destroy(rwlock);
}
static void test_cond(abts_case *tc, void *data)