apr_pool_cleanup_register(r->pool, (void *)f, modperl_filter_f_cleanup, apr_pool_cleanup_null);
static int modperl_filter_add_request(request_rec *r,                                      int idx,                                      const char *name,                                      modperl_filter_add_t addfunc,                                      const char *type,                                      ap_filter_t *filters){    MP_dDCFG;    MpAV *av;    if ((av = dcfg->handlers_per_dir[idx])) {        modperl_handler_t **handlers = (modperl_handler_t **)av->elts;        int i;        for (i=0; i<av->nelts; i++) {            modperl_filter_ctx_t *ctx;            int registered = 0;            ap_filter_t *f;            if ((handlers[i]->attrs & MP_FILTER_HTTPD_HANDLER)) {                addfunc(handlers[i]->name, NULL, r, r->connection);                MP_TRACE_f(MP_FUNC,                           "a non-mod_perl %s handler %s configured (%s)\n",                           type, handlers[i]->name, r->uri);                continue;            }            if ((handlers[i]->attrs & MP_FILTER_CONNECTION_HANDLER)) {                MP_TRACE_f(MP_FUNC,                           "%s is not a FilterRequest handler\n",                           handlers[i]->name);                continue;            }            /* XXX: I fail to see where this feature is used, since             * modperl_filter_add_connection doesn't register request             * filters. may be it'll be still useful when the same             * filter handler is configured to run more than once?             * e.g. snooping filter [stas] */            f = filters;            while (f) {                const char *fname = f->frec->name;                /* XXX: I think this won't work as f->frec->name gets                 * lowercased when added to the chain */                if (*fname == 'M' && strEQ(fname, name)) {                    modperl_handler_t *ctx_handler =                         ((modperl_filter_ctx_t *)f->ctx)->handler;                    if (modperl_handler_equal(ctx_handler, handlers[i])) {                        /* skip if modperl_filter_add_connection                         * already registered this handler                         * XXX: set a flag in the modperl_handler_t instead                         */                        registered = 1;                        break;                    }                }                f = f->next;            }            if (registered) {                MP_TRACE_f(MP_FUNC,                        "%s %s already registered\n",                        handlers[i]->name, type);                continue;            }            ctx = (modperl_filter_ctx_t *)apr_pcalloc(r->pool, sizeof(*ctx));            ctx->handler = handlers[i];            f = addfunc(name, (void*)ctx, r, r->connection);            if (handlers[i]->attrs & MP_FILTER_HAS_INIT_HANDLER &&                handlers[i]->next) {                int status = modperl_run_filter_init(                    f,                    (idx == MP_INPUT_FILTER_HANDLER                     ? MP_INPUT_FILTER_MODE : MP_OUTPUT_FILTER_MODE),                    handlers[i]->next);                if (status != OK) {                    return status;                }            }                        MP_TRACE_h(MP_FUNC, "%s handler %s configured (%s)\n",                       type, handlers[i]->name, r->uri);        }        return OK;    }    MP_TRACE_h(MP_FUNC, "no %s handlers configured (%s)\n",               type, r->uri);    return DECLINED;}