On Fri, Jun 28, 2002 at 01:28:33PM +0200, Sander Striker wrote:
> All MPMs that are creating their own allocator* (to get rid of
> locking overhead), now have the MaxMemFree directive. MaxMemFree
> allows you to set the maximum amount of memory (in kB), you want
> the child allocator to hold on to. Anything over that threshold
> is free()d back to the system. The default stays 'unlimited'.
+1 in concept.
> /me just realized we have another magic value to get rid off and instead
> do #define APR_ALLOCATOR_MAX_FREE_UNLIMITED 0, *sigh*
That'd be nice to add when you cleanup the allocator stuff to
make the types opaque. =)
> +#ifdef AP_MPM_WANT_SET_MAX_MEM_FREE
> +apr_uint32_t ap_max_mem_free = 0;
> +
> +const char *ap_mpm_set_max_mem_free(cmd_parms *cmd, void *dummy,
> + const char *arg)
> +{
> + const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
> + if (err != NULL) {
> + return err;
> + }
> +
> + ap_max_mem_free = atoi(arg) * 1024;
> +
> + return NULL;
> +}
My one caveat would be to enforce that arg is positive.
atoi() could return a negative, but it'll get casted to an
unsigned 32-bit quantity.
Or does the config core code reject negative numbers straight out?
(Way too lazy to check myself.) I think you'd be safer if you used
strtol (or better yet strtoul - strtoul is in C89, so that should be
everywhere). -- justin