mapcache icon indicating copy to clipboard operation
mapcache copied to clipboard

Add child init hook for cache backends

Open marisn opened this issue 2 years ago • 3 comments

Depending on a cache backend in use it might be necessary to perform some kind of initialization when a server worker process starts. In the case of Apache (MPM event) the child_init hook runs after a process has been created (forked) and before serving threads have been created. Currently this child_init hook is not exposed directly to cache backends and it is used only to set up connection pool. This PR adds a child_init hook for usage in any cache backend. At the moment there are no backends using this hook, although it might be required for (probably) Berkeley and (quite certainly) for TokyoCabinet backends. A LMDB cache backend requiring this hook is now under testing.

marisn avatar Aug 15 '22 12:08 marisn

OK with this patch in principle. Could you remove the changed lines where only whitespace formatting has been changed please. Also, given that very few caches actually use this, can you create a single no-op mapcache_cache_null_child_init function and reference that one instead of creating one no-op child init function per cache. thanks!

tbonfort avatar Aug 15 '22 17:08 tbonfort

It is a bit pity that the astyle script present in the code base can not be run after making modifications to files.

I replaced all cache specific child init functions with a single noop function. Should be better now.

I do not understand why tests are failing as (at least locally) I see that images are generated and seem to be fine although their checksums do not match one listed in the test script. A difference in GDAL/libjpeg?

marisn avatar Aug 26 '22 09:08 marisn

I think Travis CI check should be unplugged now: A GitHub Actions check has been activated few months ago. I just don't understand why it has not been triggered here.

jbo-ads avatar Oct 05 '22 07:10 jbo-ads

Is there anything I can do to push this forward? #293 can not be merged before this PR.

marisn avatar Jan 18 '23 14:01 marisn

fwiw, 1.14 fails to build with clang 13 on OpenBSD:

In file included from /usr/obj/ports/mapcache-1.14.0/mapcache-1.14.0/lib/axisorder.c:30:
/usr/obj/ports/mapcache-1.14.0/mapcache-1.14.0/include/mapcache.h:389:8: error: unknown type name 'inline'
static inline void mapcache_cache_child_init_noop(mapcache_context *ctx, mapcache_cache *cache, apr_pool_t *pchild) {

dropping the inline makes clang warn about unused function 'mapcache_cache_child_init_noop' but at least the build succeeds.

landryb avatar Jan 31 '23 10:01 landryb

fwiw, apparently inline fails because of forcing -std=c89

landryb avatar Jan 31 '23 10:01 landryb

fwiw, apparently inline fails because of forcing -std=c89

This doesn't seem to be right as there is no such limitation for GCC.

marisn avatar Feb 01 '23 07:02 marisn

i have no idea whether this is right or wrong, i'm just saying it fails with clang 13 in this configuration.

landryb avatar Feb 01 '23 09:02 landryb