From 714bda5580cec37ab38db2483d6e324749e9cf77 Mon Sep 17 00:00:00 2001 From: sf Date: Sat, 23 Mar 2013 16:12:00 +0000 Subject: Add apr_pool_owner_set function to allow use of pool debugging with threads Actually this function has been mentioned in the docs for over 10 years but has never been implemented. Also consistently destroy the thread's pool when it exits normally, not only on apr_thread_exit(). This was already done on OS2. Other platforms than unix are untested. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1460182 13f79535-47bb-0310-9956-ffa450edef68 --- threadproc/beos/thread.c | 7 ++++++- threadproc/netware/thread.c | 7 ++++++- threadproc/os2/thread.c | 1 + threadproc/unix/thread.c | 7 ++++++- threadproc/win32/thread.c | 7 ++++++- 5 files changed, 25 insertions(+), 4 deletions(-) (limited to 'threadproc') diff --git a/threadproc/beos/thread.c b/threadproc/beos/thread.c index 8d8383942..01bc7a973 100644 --- a/threadproc/beos/thread.c +++ b/threadproc/beos/thread.c @@ -65,7 +65,12 @@ APR_DECLARE(apr_status_t) apr_threadattr_guardsize_set(apr_threadattr_t *attr, static void *dummy_worker(void *opaque) { apr_thread_t *thd = (apr_thread_t*)opaque; - return thd->func(thd, thd->data); + void *ret; + + apr_pool_owner_set(thd->pool, 0); + ret = thd->func(thd, thd->data); + apr_pool_destroy(thd->pool); + return ret; } APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new, apr_threadattr_t *attr, diff --git a/threadproc/netware/thread.c b/threadproc/netware/thread.c index 82b846aaf..5e3d99d55 100644 --- a/threadproc/netware/thread.c +++ b/threadproc/netware/thread.c @@ -67,7 +67,12 @@ APR_DECLARE(apr_status_t) apr_threadattr_guardsize_set(apr_threadattr_t *attr, static void *dummy_worker(void *opaque) { apr_thread_t *thd = (apr_thread_t *)opaque; - return thd->func(thd, thd->data); + void *ret; + + apr_pool_owner_set(thd->pool, 0); + ret = thd->func(thd, thd->data); + apr_pool_destroy(thd->pool); + return ret; } apr_status_t apr_thread_create(apr_thread_t **new, diff --git a/threadproc/os2/thread.c b/threadproc/os2/thread.c index e2cf3f6a8..9911034ae 100644 --- a/threadproc/os2/thread.c +++ b/threadproc/os2/thread.c @@ -69,6 +69,7 @@ APR_DECLARE(apr_status_t) apr_threadattr_guardsize_set(apr_threadattr_t *attr, static void apr_thread_begin(void *arg) { apr_thread_t *thread = (apr_thread_t *)arg; + apr_pool_owner_set(thread->pool, 0); thread->exitval = thread->func(thread, thread->data); apr_pool_destroy(thread->pool); } diff --git a/threadproc/unix/thread.c b/threadproc/unix/thread.c index 5639ac706..6fc949f83 100644 --- a/threadproc/unix/thread.c +++ b/threadproc/unix/thread.c @@ -139,7 +139,12 @@ APR_DECLARE(apr_status_t) apr_threadattr_guardsize_set(apr_threadattr_t *attr, static void *dummy_worker(void *opaque) { apr_thread_t *thread = (apr_thread_t*)opaque; - return thread->func(thread, thread->data); + void *ret; + + apr_pool_owner_set(thread->pool, 0); + ret = thread->func(thread, thread->data); + apr_pool_destroy(thread->pool); + return ret; } APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new, diff --git a/threadproc/win32/thread.c b/threadproc/win32/thread.c index 9b9473ad5..c713e1444 100644 --- a/threadproc/win32/thread.c +++ b/threadproc/win32/thread.c @@ -75,8 +75,13 @@ APR_DECLARE(apr_status_t) apr_threadattr_guardsize_set(apr_threadattr_t *attr, static void *dummy_worker(void *opaque) { apr_thread_t *thd = (apr_thread_t *)opaque; + void *ret; + TlsSetValue(tls_apr_thread, thd->td); - return thd->func(thd, thd->data); + apr_pool_owner_set(thd->pool, 0); + ret = thd->func(thd, thd->data); + apr_pool_destroy(thd->pool); + return ret; } APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new, -- cgit v1.2.1