summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorYann Ylavic <ylavic@apache.org>2020-12-04 18:15:55 +0000
committerYann Ylavic <ylavic@apache.org>2020-12-04 18:15:55 +0000
commit86906a31c9829bbd78e3c1c6fb5e27416a999cfd (patch)
treeb16fdf359be66776ee053c6cdd45ec5d984491e5 /include
parent460ae3ed07e71c17d22300d0c3fe5bd53ab7681e (diff)
downloadapr-86906a31c9829bbd78e3c1c6fb5e27416a999cfd.tar.gz
Merge r936323, r1460182, r1884077, r1884078 from trunk:
OS/2: Clean up a thread's pool when it terminates. <not backported in 1.7.x> 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. </not backported in 1.7.x> 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. apr_thread: destroy the thread's pool at _join() time, unless _detach()ed. Destroying a joinable thread pool from apr_thread_exit() or when the thread function returns, i.e. from inside the thread itself, is racy or deadlocky with APR_POOL_DEBUG, with the parent pool being destroyed. This commit adds a ->detached flag in each arch's apr_thread_t struct to track whether a thread is detached (either at _create() or _detach() time). If detached, the pool is destroyed when the thread exits, otherwise when the thread is joined with apr_thread_join(). apr_thread: use unmanaged pools for detached threads. A detached thread is by definition out of control, unjoinable, unmanaged, and it can terminate/exit after its parent pool is detroyed. To avoid use-after-free in this case, let's use an unmanaged pool for detached threads, either by creating an unmanaged pool from the start if the thread is created detached, or by "unmanaging" the pool if the thread is detached later with apr_thread_detach(). To "umanage" the pool, provide a new internal helper, apr__pool_unmanage() which takes care of removing the pool from its parent's list. Submitted by: bjh, sf, ylavic, ylavic git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1884103 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'include')
-rw-r--r--include/arch/beos/apr_arch_threadproc.h1
-rw-r--r--include/arch/netware/apr_arch_threadproc.h1
-rw-r--r--include/arch/unix/apr_arch_threadproc.h1
-rw-r--r--include/arch/win32/apr_arch_threadproc.h1
4 files changed, 4 insertions, 0 deletions
diff --git a/include/arch/beos/apr_arch_threadproc.h b/include/arch/beos/apr_arch_threadproc.h
index 13de05363..b7db0a300 100644
--- a/include/arch/beos/apr_arch_threadproc.h
+++ b/include/arch/beos/apr_arch_threadproc.h
@@ -45,6 +45,7 @@ struct apr_thread_t {
void *data;
apr_thread_start_t func;
apr_status_t exitval;
+ int detached;
};
struct apr_threadattr_t {
diff --git a/include/arch/netware/apr_arch_threadproc.h b/include/arch/netware/apr_arch_threadproc.h
index 2fee2c00e..ce217aaba 100644
--- a/include/arch/netware/apr_arch_threadproc.h
+++ b/include/arch/netware/apr_arch_threadproc.h
@@ -36,6 +36,7 @@ struct apr_thread_t {
void *data;
apr_thread_start_t func;
apr_status_t exitval;
+ int detached;
};
struct apr_threadattr_t {
diff --git a/include/arch/unix/apr_arch_threadproc.h b/include/arch/unix/apr_arch_threadproc.h
index 7a3b3c092..adeb51c8a 100644
--- a/include/arch/unix/apr_arch_threadproc.h
+++ b/include/arch/unix/apr_arch_threadproc.h
@@ -59,6 +59,7 @@ struct apr_thread_t {
void *data;
apr_thread_start_t func;
apr_status_t exitval;
+ int detached;
};
struct apr_threadattr_t {
diff --git a/include/arch/win32/apr_arch_threadproc.h b/include/arch/win32/apr_arch_threadproc.h
index d3ce9c518..b39fdbbea 100644
--- a/include/arch/win32/apr_arch_threadproc.h
+++ b/include/arch/win32/apr_arch_threadproc.h
@@ -31,6 +31,7 @@ struct apr_thread_t {
void *data;
apr_thread_start_t func;
apr_status_t exitval;
+ int exited;
};
struct apr_threadattr_t {