summaryrefslogtreecommitdiffstats
path: root/server/main.c
diff options
context:
space:
mode:
authorYann Ylavic <ylavic@apache.org>2022-01-27 13:34:53 +0100
committerYann Ylavic <ylavic@apache.org>2022-01-27 13:34:53 +0100
commit3e0035d1892b7e8506cc2f53921282aaab8e4c23 (patch)
tree6a09f29bd2fff2bd884779d06faf9eda8712ca4f /server/main.c
parentcore: Follow up to r1897460: Implement and use ap_thread_current_after_fork(). (diff)
downloadapache2-3e0035d1892b7e8506cc2f53921282aaab8e4c23.tar.xz
apache2-3e0035d1892b7e8506cc2f53921282aaab8e4c23.zip
core: Follow up to r1897460: Provide ap_thread_main_create().
Replace ap_thread_current_create() by ap_thread_main_create() which is how it's used by httpd. The former is now a local helper only to implement the latter. This allows to consolidate/factorize common code in the main() of httpd and the unix MPMs. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1897543 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'server/main.c')
-rw-r--r--server/main.c29
1 files changed, 5 insertions, 24 deletions
diff --git a/server/main.c b/server/main.c
index 2ca2aea15d..2681521542 100644
--- a/server/main.c
+++ b/server/main.c
@@ -339,15 +339,6 @@ static void reset_process_pconf(process_rec *process)
apr_pool_pre_cleanup_register(process->pconf, NULL, deregister_all_hooks);
}
-#if AP_HAS_THREAD_LOCAL
-static apr_status_t main_thread_cleanup(void *arg)
-{
- apr_thread_t *thd = arg;
- apr_pool_destroy(apr_thread_pool_get(thd));
- return APR_SUCCESS;
-}
-#endif
-
static process_rec *init_process(int *argc, const char * const * *argv)
{
process_rec *process;
@@ -400,28 +391,18 @@ static process_rec *init_process(int *argc, const char * const * *argv)
process->short_name = apr_filepath_name_get((*argv)[0]);
#if AP_HAS_THREAD_LOCAL
- /* Create an apr_thread_t for the main thread to set up its
- * Thread Local Storage. Since it's detached and it won't
- * apr_thread_exit(), destroy its pool before exiting via
- * a process->pool cleanup
- */
{
- apr_thread_t *main_thd = NULL;
- apr_threadattr_t *main_thd_attr = NULL;
- if (apr_threadattr_create(&main_thd_attr, process->pool)
- || apr_threadattr_detach_set(main_thd_attr, 1)
- || ap_thread_current_create(&main_thd, main_thd_attr,
- process->pool)) {
+ apr_status_t rv;
+ apr_thread_t *thd = NULL;
+ if ((rv = ap_thread_main_create(&thd, process->pool))) {
char ctimebuff[APR_CTIME_LEN];
apr_ctime(ctimebuff, apr_time_now());
fprintf(stderr, "[%s] [crit] (%d) %s: %s failed "
- "to initialize thread context, exiting\n",
- ctimebuff, stat, (*argv)[0], failed);
+ "to initialize thread context (%i), exiting\n",
+ ctimebuff, stat, (*argv)[0], failed, rv);
apr_terminate();
exit(1);
}
- apr_pool_cleanup_register(process->pool, main_thd, main_thread_cleanup,
- apr_pool_cleanup_null);
}
#endif