On Fri, Aug 23, 2019 at 2:35 PM Eric Covener <cove...@gmail.com> wrote:
>
> I have a question in this area, not necessarily a result of this commit.
>
> I have been playing with a new crypto provider, in a non-DSO build,
> intended to be used with httpd.
>
> The provider does have both an initialization and termination API.
>
> My issue is a result of the "rootp" being used for the driver hashmap
> but "pconf" (in the httpd/mod_session_crypto case) being passed to the
> drivers init() function the first time it's loaded.  This means at
> graceful restart, cleanups registered by the drivers init() function
> will run, but apr_crypto_term will not, and the next call to get the
> driver will not re-run the init().
>
> Making the lifetimes match either way fixes my test -- either moving
> the "rootp" stuff to DSO-only for apr_crypto_init or by passing
> "rootp" to the DRIVER_LOAD macro for non-DSO init.
>
> Any opinions?

Was this resolved?

It seems to me that in the !DSO case we should init the driver with
the given pool and call init each time like in the DSO case.
Something like the attached patch?


Cheers;
Yann.
Index: crypto/apr_crypto.c
===================================================================
--- crypto/apr_crypto.c	(revision 1893265)
+++ crypto/apr_crypto.c	(working copy)
@@ -90,12 +90,15 @@ static apr_status_t apr_crypto_term(void *ptr)
 
 APR_DECLARE(apr_status_t) apr_crypto_init(apr_pool_t *pool)
 {
+#if APR_HAVE_MODULAR_DSO
     apr_pool_t *rootp;
+#endif
 
     if (drivers != NULL) {
         return APR_SUCCESS;
     }
 
+#if APR_HAVE_MODULAR_DSO
     /* Top level pool scope, for drivers' process-scope lifetime */
     rootp = pool;
     for (;;) {
@@ -105,13 +108,16 @@ APR_DECLARE(apr_status_t) apr_crypto_init(apr_pool
         }
         rootp = p;
     }
-#if APR_HAVE_MODULAR_DSO
     /* deprecate in 2.0 - permit implicit initialization */
     apu_dso_init(rootp);
-#endif
     drivers = apr_hash_make(rootp);
     apr_pool_cleanup_register(rootp, NULL, apr_crypto_term,
                               apr_pool_cleanup_null);
+#else
+    drivers = apr_hash_make(pool);
+    apr_pool_cleanup_register(pool, NULL, apr_crypto_term,
+                              apr_pool_cleanup_null);
+#endif
 
     return APR_SUCCESS;
 }
@@ -280,7 +286,7 @@ APR_DECLARE(apr_status_t) apr_crypto_get_driver(
         }
     }
 
-#else /* not builtin and !APR_HAS_DSO => not implemented */
+#else /* not builtin and !APR_HAVE_MODULAR_DSO => not implemented */
     rv = APR_ENOTIMPL;
 
     /* Load statically-linked drivers: */

Reply via email to