httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Locke <>
Subject Help w/server config code
Date Thu, 17 Jun 2010 15:42:15 GMT
I incorrectly posted this question on http-dev.
I have a written a simple module for 2.0 where I wish to read configuration
only from the main server config.
I get a segfault when it walks the configuration though. I have created an
even simpler example which I will include at the end.
Basically when apache is reading the configuration from the conf file and it
gets to my setting, it fails. In ap_walk_config_sub (config.c) the
section_vector is always null.

My module only implements the ap_hook_fixups method. (Not sure if that

Thanks for your consideration.


--------------------------- begin mod_jcp_test.c -------------------------

#include "httpd.h"
#include "http_config.h"
#include "http_core.h"
#include "http_log.h"
#include "http_protocol.h"
#include "http_request.h"

/* Apache 2.1+ */
#include "ap_provider.h"
#include "apr.h"
#include "apr_lib.h"
#include "apr_buckets.h"
#include "apr_strings.h"

#include "apr_hash.h"
#include "apr_want.h"

/* apache module name */
module AP_MODULE_DECLARE_DATA mod_jcp_test;

/* config structure */
typedef struct {
char * szHeaderValue;
} server_config;

static apr_status_t ap_headers_fixup(request_rec *r)
server_config *conf=NULL;
char *szHeaderVariableName = "JCPPORTAL";

/* Do not run in subrequests */
    if (r->main) {
        return DECLINED;

/* get apache config */
conf = ap_get_module_config(r->server->module_config, &mod_jcp_test);
 apr_table_setn(r->headers_in, szHeaderVariableName, conf->szHeaderValue);

return OK;

static void register_hooks(apr_pool_t* pool)
ap_hook_fixups(ap_headers_fixup, NULL, NULL, APR_HOOK_LAST);

static void *create_server_config(apr_pool_t *p, server_rec *s)
server_config *conf = apr_pcalloc(p, sizeof(server_config));
conf->szHeaderValue= apr_pstrdup(p,"FredFlinstone");
return conf;

static const command_rec Mod_jcp_test_cmds[] =
AP_INIT_TAKE1("Mod_jcp_test_header_value", ap_set_string_slot,
(void *)APR_OFFSETOF(server_config, szHeaderValue),
OR_ALL, "Some text to stick in the header."),


/* apache module structure */
module AP_MODULE_DECLARE_DATA mod_jcp_test =
NULL, /* dir config creater */
NULL,                       /* dir merger --- default is to override */
create_server_config,  /* server config */
NULL,                       /* merge server config */
Mod_jcp_test_cmds,   /* command apr_table_t */
register_hooks              /* register hooks */

--------------------------- end mod_jcp_test.c -------------------------

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message