在初始化的Apache2模块 [英] Init modules in apache2

查看:173
本文介绍了在初始化的Apache2模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以前写的Apache 1.3 Apache模块,但这些天我愿意传递到Apache2的。 ,我目前写的模块已经被自己的二进制数据,而不是一个数据库,出于性能的目的。我需要在共享内存中加载这些数据,所以每个孩子都可以访问它,而不做他自己的副本,这将是实际的加载/启动时创建的二进制数据,因为我使用的Apache 1.3做。问题是,我没有在模块结构发现的Apache2 init事件,在1.3,STANDARD_MODULE_STUFF后立刻找到了/ **模块初始化的地方* /,其中你可以把将要及早执行的函数。
我以前写的函数体是一样的东西:

I used to write apache modules in apache 1.3, but these days I am willing to pass to apache2. The module that I am writing at the moment has is own binary data, not a database, for performance purposes. I need to load this data in shared memory, so every child can access it without making his own copy, and it would be practical to load/create the binary data at startup, as I was used to do with apache 1.3. Problem is that I don't find an init event in apache2, in 1.3 in the module struct, immediatly after STANDARD_MODULE_STUFF you find a place for a /** module initializer */, in which you can put a function that will be executed early. Body of the function I used to write is something like:

if ( getppid == 1 )
{
     // Load global data here
     // this is the parent process
     void* data = loadGlobalData( someFilePath );
     setGlobalData( config, data );
}
else
{
    // this is the init of a child process
    // do nothing
}

我要寻找一个在Apache2的一个地方在我可以把类似的功能。

I am looking for a place in apache2 in where I can put a similar function.

您能帮我吗?

谢谢
本韦努托

Thanks Benvenuto

推荐答案

既然你想要的服务器上创建一个单一的共享内存段供所有儿童使用,我会建议在后配置挂钩(ap_hook_post_config)初始化这一点。一旦配置已经读这就是所谓的,但孩子们都催生之前,所以它应该很好地工作。

Since you want the server to create a single shared memory segment to be used by all children, I would recommend initialising this in the post config hook (ap_hook_post_config). This is called once the configuration has been read, but before the children are spawned, so it should work well.

这篇关于在初始化的Apache2模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆