summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorYann Ylavic <ylavic@apache.org>2022-07-15 09:24:01 +0000
committerYann Ylavic <ylavic@apache.org>2022-07-15 09:24:01 +0000
commit5382f96a3a0708c050ece38cf70ad8d6808b882c (patch)
tree16b7c99ca65d9c2b288ed7a501e1169672050105 /include
parente1625133b1117c51cfce1088eff09b44fe792cb4 (diff)
downloadhttpd-5382f96a3a0708c050ece38cf70ad8d6808b882c.tar.gz
core: Apply ap_max_mem_free to created threads' pool allocator.
Since APR does not set the threshold above which the allocator of the thread's starts returning its memory to the system, so set ap_max_mem_free from ap_thread_create(), ap_thread_main_create() and ap_thread_current_create(). * include/httpd.h: Provide our own ap_thread_create() in any case (but !APR_HAS_THREADS). Simplify #ifdef-ery. * server/util.c(thread_start, ap_thread_main_create, ap_thread_current_create): Set ap_max_mem_free to the thread's pool allocator. Simplify #ifdef-ery. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1902728 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'include')
-rw-r--r--include/httpd.h56
1 files changed, 26 insertions, 30 deletions
diff --git a/include/httpd.h b/include/httpd.h
index a4c32535c7..1ef00212f4 100644
--- a/include/httpd.h
+++ b/include/httpd.h
@@ -2571,27 +2571,35 @@ AP_DECLARE(void *) ap_realloc(void *ptr, size_t size)
#if APR_HAS_THREADS
-#if APR_VERSION_AT_LEAST(1,8,0) && !defined(AP_NO_THREAD_LOCAL)
+/* apr_thread_create() wrapper that handles thread pool limits and
+ * ap_thread_current() eventually (if not handle by APR already).
+ */
+AP_DECLARE(apr_status_t) ap_thread_create(apr_thread_t **thread,
+ apr_threadattr_t *attr,
+ apr_thread_start_t func,
+ void *data, apr_pool_t *pool);
+
+/* Make the main() thread ap_thread_current()-able. */
+AP_DECLARE(apr_status_t) ap_thread_main_create(apr_thread_t **thread,
+ apr_pool_t *pool);
+
+#if APR_VERSION_AT_LEAST(1,8,0)
/**
- * APR 1.8+ implement those already.
+ * Use APR 1.8+ implementation.
*/
-#if APR_HAS_THREAD_LOCAL
-#define AP_HAS_THREAD_LOCAL 1
-#define AP_THREAD_LOCAL APR_THREAD_LOCAL
-#else
-#define AP_HAS_THREAD_LOCAL 0
+#if APR_HAS_THREAD_LOCAL && !defined(AP_NO_THREAD_LOCAL)
+#define AP_THREAD_LOCAL APR_THREAD_LOCAL
#endif
-#define ap_thread_create apr_thread_create
#define ap_thread_current apr_thread_current
#define ap_thread_current_create apr_thread_current_create
#define ap_thread_current_after_fork apr_thread_current_after_fork
-#else /* APR_VERSION_AT_LEAST(1,8,0) && !defined(AP_NO_THREAD_LOCAL) */
+#else /* APR_VERSION_AT_LEAST(1,8,0) */
-#ifndef AP_NO_THREAD_LOCAL
+#if !defined(AP_NO_THREAD_LOCAL)
/**
- * AP_THREAD_LOCAL keyword mapping the compiler's.
+ * AP_THREAD_LOCAL keyword aliases the compiler's.
*/
#if defined(__cplusplus) && __cplusplus >= 201103L
#define AP_THREAD_LOCAL thread_local
@@ -2604,18 +2612,7 @@ AP_DECLARE(void *) ap_realloc(void *ptr, size_t size)
#elif defined(WIN32) && defined(_MSC_VER)
#define AP_THREAD_LOCAL __declspec(thread)
#endif
-#endif /* ndef AP_NO_THREAD_LOCAL */
-
-#ifndef AP_THREAD_LOCAL
-#define AP_HAS_THREAD_LOCAL 0
-#define ap_thread_create apr_thread_create
-#else /* AP_THREAD_LOCAL */
-#define AP_HAS_THREAD_LOCAL 1
-AP_DECLARE(apr_status_t) ap_thread_create(apr_thread_t **thread,
- apr_threadattr_t *attr,
- apr_thread_start_t func,
- void *data, apr_pool_t *pool);
-#endif /* AP_THREAD_LOCAL */
+#endif /* !defined(AP_NO_THREAD_LOCAL) */
AP_DECLARE(apr_status_t) ap_thread_current_create(apr_thread_t **current,
apr_threadattr_t *attr,
@@ -2623,16 +2620,15 @@ AP_DECLARE(apr_status_t) ap_thread_current_create(apr_thread_t **current,
AP_DECLARE(void) ap_thread_current_after_fork(void);
AP_DECLARE(apr_thread_t *) ap_thread_current(void);
-#endif /* APR_VERSION_AT_LEAST(1,8,0) && !defined(AP_NO_THREAD_LOCAL) */
-
-AP_DECLARE(apr_status_t) ap_thread_main_create(apr_thread_t **thread,
- apr_pool_t *pool);
+#endif /* APR_VERSION_AT_LEAST(1,8,0) */
-#else /* APR_HAS_THREADS */
+#endif /* APR_HAS_THREADS */
+#ifdef AP_THREAD_LOCAL
+#define AP_HAS_THREAD_LOCAL 1
+#else
#define AP_HAS_THREAD_LOCAL 0
-
-#endif /* APR_HAS_THREADS */
+#endif
/**
* Get server load params