Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9228163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:15:21+00:00 2026-06-18T05:15:21+00:00

I wrote the module code like this: static void *example_create_server_config(apr_pool_t *p, server_rec *s) {

  • 0

I wrote the module code like this:

static void *example_create_server_config(apr_pool_t *p, server_rec *s)
{
  syslog(LOG_ERR, "create_server_config");
  // create my handler
  // my_handler_t *handler = (my_handler_t *)apr_palloc(pool, sizeof(my_handler_t));
  return NULL;
}

/* Dispatch list for API hooks */ 
module AP_MODULE_DECLARE_DATA example_module = {
    STANDARD20_MODULE_STUFF,
    NULL,                               /* create per-dir    config structures */
    NULL,                               /* merge  per-dir    config structures */
    example_create_server_config,       /* create per-server config structures */
    NULL,                               /* merge  per-server config structures */
    example_cmds,                       /* table of config file commands       */
    example_register_hooks              /* register hooks                      */
};

When I restart Apache, the /var/log/syslog contains this:

Jan 31 14:46:49 su02 apache2: create_server_config
Jan 31 14:46:49 su02 apache2: create_server_config
Jan 31 14:46:49 su02 apache2: child_init

Why is the create_server_config function be called twice?

I malloc some global variables in this function. Is that safe or not?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T05:15:22+00:00Added an answer on June 18, 2026 at 5:15 am

    It is perfectly safe to acquire memory using the apr_pool_t pointer that you receive inside of this function. Also, this function will be invoked once for every server/host configuration you have in your httpd.conf file, so that’s why you see multiple calls to this function. For example a root server configuration and one configuration section would make this function be invoked twice.

    typedef struct
    {
        int value;
    } my_srv_cfg;
    
    static void *example_create_server_config(apr_pool_t *pool, server_rec *s)
    {
        my_srv_cfg *new = apr_pcalloc(pool, sizeof (*new));
        new->value = 100;
        return new; 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote code like this >>> class a(object): def __init__(self): self.__call__ = lambda x:x
i wrote some helper methods for my application like this module Magick class Draw
If I add an HTTP module in the web.config file like this: <httpModules> <add
I have a model like this: class Item(models.Model): code = models.CharField(max_length=200, unique=True) barcode =
I'm really confused, I wrote this code and I'm trying to pull in some
When I run a simple bit of code like this: my @arr=(1..5); my $x;
e.g. if you have code that does something like this somewhere in your codebase:
How to write this JavaScript code without eval? var typeOfString = eval(typeof + that.modules[modName].varName);
I wrote a python module. Running python filename.py, only checks for syntax errors. Is
I'm trying to distribute a python module I wrote. For some reason, I can't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.