On 23 Feb 2022, at 12:39, Stefan Eissing <ste...@eissing.org> wrote:

> One thing that is currently missing is a way to shutdown/reap/join module 
> threads when the mpm exits.
> 
> Example: 
> 
> mod_watchdog creates several threads post_config which are only joined on 
> pool destruction.
> 
> Problem:
> 
> pool destruction is not ordered between modules and dependencies on order are 
> not
> fully known. This leads to crashes in OpenSSL, for example, when mod_ssl is 
> destructed
> before all watchdogs using OpenSSL are joined (OpenSSL 3.x seems to do better 
> on this, 
> but the point remains valid).

A note on OpenSSL termination - in old versions of OpenSSL, there was this 
wrong assumption that an application would only ever initialise OpenSSL once, 
and in turn shut down OpenSSL once, but this scenario doesn’t exist in the real 
world (like ours, where modules that have no idea about each other 
independently use OpenSSL).

OpenSSL 3 (and I think earlier versions, I don’t remember) have gone further 
than “do better”, they have (to my knowledge) 100% fixed this problem by 
turning all OpenSSL init functions into noops and using reference counting 
internally to ensure sanity is maintained at all times.

If any of this doesn't work, we need to let OpenSSL know.

> There has been attempts by Yann to make a patch that make the OpenSSL 
> termination
> way later (adding it to a 'higher' pool destruction). But that would only 
> solve
> this particular problem and not any other 3rd party dependency.
> 
> Proposal:
> 
> Add a hook 'child_exiting(int graceful)' where modules can register
> and do their own thread join/reap.
> 
> 
> On a graceful shutdown, this would allow watchdogs to fully complete any 
> ongoing task
> before things start to disappear in the process.

+1 - will be very useful.

Regards,
Graham
—

Reply via email to