]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
mod_ssl_ct: join the threads before their parent pools are destroyed.
authorYann Ylavic <ylavic@apache.org>
Fri, 20 Nov 2020 16:31:21 +0000 (16:31 +0000)
committerYann Ylavic <ylavic@apache.org>
Fri, 20 Nov 2020 16:31:21 +0000 (16:31 +0000)
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

modules/ssl/mod_ssl_ct.c

index c2de848d382eb5d9815c28465a009265a941d3cc..535ea4449e73df7a4cdb684d5b54e5d5d6e0224c 100644 (file)
@@ -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,