Open khklau opened 3 years ago
Apparently Apache 2.4 provides access to a memory pool per thread.
After more research the pool is designed as a per request heap.
For allocations within a hook callback or per thread lifetime a non-pool allocator is allowed, albeit it must be the same system allocator used by Apache, which would be the Glibc allocator.
The pattern for Apache modules to store request metadata is: 1) Use the pool in request_rec to allocate space for your metadata structure 2) Save the pointer the metadata structure in the request_config field of request_rec via ap_set_module_config
There are a number of memory pools available for use:
Now that issue#7 is resolved we don't need the memory pools for convenient allocation since nothing is more convenient than the global allocator.
Having values with lifetimes bound to a configuration, connection or request however is still useful.
Some initial idea for how this could be implemented are:
The plan is to now:
As an alternative PoolBox might not even be needed. The context structs can be constructed on the heap via the global allocator and the context can be forcefully dropped via the cleanup function that is registered to the pool.
In Apache2 modules allocating from the heap via any malloc implementation is forbidden. Instead modules are expected to allocate via the supplied APR memory pools.
To allow the std Rust containers to be used the APR memory pool must be adapted to fit one of the allocator traits and it must be set as the default global allocator.