On 1/25/22 9:28 PM, yla...@apache.org wrote:
> Author: ylavic
> Date: Tue Jan 25 20:28:28 2022
> New Revision: 1897472
> 
> URL: http://svn.apache.org/viewvc?rev=1897472&view=rev
> Log:
> core: Follow up to r1897460: Implement and use ap_thread_current_after_fork().
> 
> thread_local variables are not (always?) reset on fork(), so we need a way
> to set the current_thread to NULL in the child process.
> 
> Implement and use ap_thread_current_after_fork() for that.
> 
> * include/httpd.h:
>   Define ap_thread_current_after_fork().
> 
> * server/util.c:
>   Implement ap_thread_current_after_fork().
> 
> * server/mpm/event/event.c, server/mpm/prefork/prefork.c,
>     server/mpm/worker/worker.c:
>   Use ap_thread_current_after_fork().
> 
> * server/mpm/winnt/child.c:
>   Windows processes are not fork()ed and each child runs the main(), so
>   ap_thread_current_create() was already called there.
> 
> 
> Modified:
>     httpd/httpd/trunk/include/httpd.h
>     httpd/httpd/trunk/server/mpm/event/event.c
>     httpd/httpd/trunk/server/mpm/prefork/prefork.c
>     httpd/httpd/trunk/server/mpm/winnt/child.c
>     httpd/httpd/trunk/server/mpm/worker/worker.c
>     httpd/httpd/trunk/server/util.c
> 

> Modified: httpd/httpd/trunk/server/mpm/winnt/child.c
> URL: 
> http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/winnt/child.c?rev=1897472&r1=1897471&r2=1897472&view=diff
> ==============================================================================
> --- httpd/httpd/trunk/server/mpm/winnt/child.c (original)
> +++ httpd/httpd/trunk/server/mpm/winnt/child.c Tue Jan 25 20:28:28 2022
> @@ -891,15 +891,6 @@ static void create_listener_thread(void)
>  }
>  
>  
> -#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
> -
>  void child_main(apr_pool_t *pconf, DWORD parent_pid)
>  {
>      apr_status_t status;
> @@ -921,28 +912,6 @@ void child_main(apr_pool_t *pconf, DWORD
>      apr_pool_create(&pchild, pconf);
>      apr_pool_tag(pchild, "pchild");
>  
> -#if AP_HAS_THREAD_LOCAL
> -    /* Create an apr_thread_t for the main child 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 pchild cleanup
> -     */
> -    {
> -        apr_thread_t *main_thd = NULL;
> -        apr_threadattr_t *main_thd_attr = NULL;
> -        if (apr_threadattr_create(&main_thd_attr, pchild)
> -                || apr_threadattr_detach_set(main_thd_attr, 1)
> -                || ap_thread_current_create(&main_thd, main_thd_attr,
> -                                            pchild)) {
> -            ap_log_error(APLOG_MARK, APLOG_EMERG, 0, ap_server_conf, 
> APLOGNO(10376)
> -                         "Couldn't initialize child main thread");
> -            exit(APEXIT_CHILDINIT);
> -        }
> -        apr_pool_cleanup_register(pchild, main_thd, main_thread_cleanup,
> -                                  apr_pool_cleanup_null);
> -    }
> -#endif
> -
>      ap_run_child_init(pchild, ap_server_conf);
>  
>      listener_shutdown_event = CreateEvent(NULL, TRUE, FALSE, NULL);
> 

Why is this no longer needed?

Regards

RĂ¼diger

Reply via email to