httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tony Abo <>
Subject RE: Cleanup when server is stopped vs reconfigured
Date Tue, 29 Mar 2016 11:39:03 GMT
> > Is there a way to run some cleanup code in a module when the server is
> being stopped, but not being restarted? Or, can a cleanup handler in a loaded
> module determine whether the server is being shut down or restarted?
> With 2.4.x, you could use the ap_pglobal pool.
> Beware this should be done only once by register_hooks (called at every
> restart), so something like:
> {
>     void *data;
>     apr_pool_userdata_get(&data, "my_module_key", ap_pglobal);
>     if (!data) {
>         char *key = apr_pstrdup(ap_pglobal, "my_module_key");
>         apr_pool_userdata_set(key, key, apr_pool_cleanup_null, ap_pglobal);
>     }
> }

Thanks for your suggestion. I am not yet on 2.4.x. 

Is ap_pglobal available to DSO modules? 

Also, if I register a cleanup handler for that pool, will the cleanup function get called
before my module is unloaded? I think in previous versions the server unloads all of the loaded
modules before destroying the global pool. That would lead to a crash.

View raw message