我这样编写模块代码:
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 */
};
当我重新启动 Apache 时,其中/var/log/syslog
包含以下内容:
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
为什么create_server_config
函数被调用两次?
我在这个函数中 malloc 了一些全局变量。这安全吗?