Subsystem "thread_cleanup" is never called
Subsystems implement the interface of
struct subsys_fns_t, with one of the optional function pointers being
void (*thread_cleanup)(void). This
thread_cleanup function is called for all subsystems by the subsystem manager function
void subsystems_thread_cleanup(void), but the
subsystems_thread_cleanup function is never called anywhere in the code.
At the moment, the only subsystem to implement the
thread_cleanup interface is the crypto subsystem, which uses
thread_cleanup for freeing the threadlocal
crypto_fast_rng_t, as well as freeing the threadlocal error queue on old versions of OpenSSL. As far as I can tell, this is never run.
I think that the
subsystems_thread_cleanup function should be run somewhere in the code, but it's not clear to me how this
subsystems_thread_cleanup is expected to be used. It seems like there should also be
thread_init functions as well for initializing threadlocal variables. Right now the crypto subsystem does an "initialize on first use" singleton pattern, but it might be useful to add this initialization interface function so that subsystems have the option of initializing all of their threadlocals in one place.