From: Yann Ylavic Date: Fri, 20 Nov 2020 16:31:21 +0000 (+0000) Subject: mod_ssl_ct: join the threads before their parent pools are destroyed. X-Git-Tag: 2.5.0-alpha2-ci-test-only~1142 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=adb6b3ce7d67c9738ac6f403647d5914a76329d3;p=thirdparty%2Fapache%2Fhttpd.git mod_ssl_ct: join the threads before their parent pools are destroyed. This can happen on stop/restart for the daeomon thread, or on clean_child_exit() for the service thread. When an apr_thread_create()d thread exits it destroys its pool (in any case), either explicitely when apr_thread_exit() is called, or implicitely after the function returns (only in APR 2.0 for now). So we should make sure that mod_ssl_ct's daemon and service threads exit before pconf and pchild (the parent pools, respectively) destroy their children pools, otherwise the threads' pool will be destroyed twice and cause a crash. Using a pre_cleanup to wait for the threads avoids this. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1883667 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/ssl/mod_ssl_ct.c b/modules/ssl/mod_ssl_ct.c index c2de848d382..535ea4449e7 100644 --- a/modules/ssl/mod_ssl_ct.c +++ b/modules/ssl/mod_ssl_ct.c @@ -864,6 +864,7 @@ static void * APR_THREAD_FUNC run_service_thread(apr_thread_t *me, void *data) ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, s, APLOGNO(03243) SERVICE_THREAD_NAME " exiting"); + apr_thread_exit(me, APR_SUCCESS); return NULL; } @@ -1112,6 +1113,7 @@ static void *sct_daemon_thread(apr_thread_t *me, void *data) ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(03246) DAEMON_THREAD_NAME " - exiting"); + apr_thread_exit(me, APR_SUCCESS); return NULL; } @@ -1130,8 +1132,7 @@ static int daemon_thread_start(apr_pool_t *pconf, server_rec *s_main) return HTTP_INTERNAL_SERVER_ERROR; } - apr_pool_cleanup_register(pconf, daemon_thread, wait_for_thread, - apr_pool_cleanup_null); + apr_pool_pre_cleanup_register(pconf, daemon_thread, wait_for_thread); return OK; } @@ -2532,8 +2533,7 @@ static void ssl_ct_child_init(apr_pool_t *p, server_rec *s) exit(APEXIT_CHILDSICK); } - apr_pool_cleanup_register(p, service_thread, wait_for_thread, - apr_pool_cleanup_null); + apr_pool_pre_cleanup_register(p, service_thread, wait_for_thread); if (sconf->proxy_awareness != PROXY_OBLIVIOUS) { rv = apr_thread_mutex_create(&cached_server_data_mutex,