@@ -693,14 +693,10 @@ typedef struct oidc_cfg_cleanup_ctx_t {
693693/*
694694 * destroy a server config record and its members
695695 */
696- static apr_status_t oidc_cfg_server_destroy (void * data ) {
697- oidc_cfg_cleanup_ctx_t * ctx = (oidc_cfg_cleanup_ctx_t * )data ;
698- oidc_cfg_t * cfg = ctx -> cfg ;
699- if (cfg -> cache .impl && cfg -> cache .impl -> destroy ) {
700- cfg -> cache .impl -> destroy (ctx -> pool , ctx -> svr );
701- cfg -> cache .impl -> destroy = NULL ;
702- cfg -> cache .impl = NULL ;
703- }
696+ apr_byte_t oidc_cfg_server_destroy (apr_pool_t * pool , server_rec * s , oidc_cfg_t * cfg ) {
697+ if ((cfg -> cache .impl ) && (cfg -> cache .impl -> destroy ))
698+ cfg -> cache .impl -> destroy (pool , s );
699+ cfg -> cache .impl = NULL ;
704700 oidc_cfg_provider_destroy (cfg -> provider );
705701 cfg -> provider = NULL ;
706702 oidc_cfg_oauth_destroy (cfg -> oauth );
@@ -709,18 +705,25 @@ static apr_status_t oidc_cfg_server_destroy(void *data) {
709705 cfg -> public_keys = NULL ;
710706 oidc_jwk_list_destroy (cfg -> private_keys );
711707 cfg -> private_keys = NULL ;
712- return APR_SUCCESS ;
708+ return TRUE;
709+ }
710+
711+ static apr_status_t oidc_cfg_server_cleanup (void * data ) {
712+ oidc_cfg_cleanup_ctx_t * ctx = (oidc_cfg_cleanup_ctx_t * )data ;
713+ oidc_cfg_t * cfg = ctx -> cfg ;
714+ return oidc_cfg_server_destroy (ctx -> pool , ctx -> svr , cfg ) ? APR_SUCCESS : APR_EGENERAL ;
713715}
714716
715- static oidc_cfg_t * oidc_cfg_server_alloc (apr_pool_t * pool , server_rec * svr ) {
717+ static oidc_cfg_t * oidc_cfg_server_alloc (apr_pool_t * pool , server_rec * s ) {
716718 oidc_cfg_t * c = apr_pcalloc (pool , sizeof (oidc_cfg_t ));
717719 oidc_cfg_cleanup_ctx_t * ctx = apr_pcalloc (pool , sizeof (oidc_cfg_cleanup_ctx_t ));
718720 ctx -> cfg = c ;
719- // pool used at descrution time
721+ // pconf pool used at destruction time
720722 ctx -> pool = pool ;
721- ctx -> svr = svr ;
722- // need to register a cleanup handler to the config pool to handle graceful restarts without memory leaks
723- apr_pool_cleanup_register (pool , ctx , oidc_cfg_server_destroy , oidc_cfg_server_destroy );
723+ ctx -> svr = s ;
724+ // need to register a cleanup handler to the config pool to handle graceful restarts without memory increasing
725+ // memory consumption
726+ apr_pool_cleanup_register (pool , ctx , oidc_cfg_server_cleanup , apr_pool_cleanup_null );
724727 return c ;
725728}
726729
@@ -1040,7 +1043,7 @@ void oidc_cfg_child_init(apr_pool_t *pool, oidc_cfg_t *cfg, server_rec *s) {
10401043 }
10411044}
10421045
1043- void oidc_cfg_cleanup_child (oidc_cfg_t * cfg , server_rec * s ) {
1046+ void oidc_cfg_process_cleanup (oidc_cfg_t * cfg , server_rec * s ) {
10441047 if (_oidc_refresh_mutex != NULL ) {
10451048 if (oidc_cache_mutex_destroy (s , _oidc_refresh_mutex ) != TRUE) {
10461049 oidc_serror (s , "oidc_cache_mutex_destroy on refresh mutex failed" );
0 commit comments