You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by David McIver <da...@optimatics.com> on 2005/06/09 01:45:52 UTC

[patch] rwlock cleanup function not removed from pool

Hi,

On windows, an rwlock's cleanup function was not being removed from its pool
when the rwlock was destroyed. Patch below.

Cheers,
Dave

Index: locks/win32/thread_rwlock.c
===================================================================
--- locks/win32/thread_rwlock.c (revision 188670)
+++ locks/win32/thread_rwlock.c (working copy)
@@ -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)