精通
英语
和
开源
,
擅长
开发
与
培训
,
胸怀四海
第一信赖
锐英源精品开源心得,转载请注明:“锐英源www.wisestudy.cn,孙老师作品,电话13803810136。需要全文内容也请联系孙老师。
In addition to the callback routines used to manage a module’s private configuration information, there are a few additional hooks which your module structure can declare: 除了用于管理模块的专用配置信息的回调例程,你的模块结构也可以声明另外一些额外的钩子:
· The init hook allows your module to do any one-time initial setup it needs. The only argument to this hook is a pool pointer, however, which makes it very difficult to pass information to other callbacks made later. An example use for this callback might be to set up a connexion to a database server.
init钩子允许您的模块做任何它需要的一次性初始设置。这个钩子的唯一参数是一个内存池指针,不过,这让我们很难将信息传递给后作出的其他回调,用于这个回调的一个例子可能是建立一个连接到数据库服务器。
Note: One thing that serves as an endless source of confusion is that this callback is invoked twice. Don’t ask why; it’s a legacy thing from the early days of Apache. Just be aware of the fact, and don’t be surprised by it. 注意:最混乱的一件事是被调用两次。不要问为什么,这是早期Apache遗留的问题。只要知道就好,不必惊讶。
· Similar to the init callback, the child_init hook is available to modules that want or need to setup processing of some sort. The difference between this callback and the init callback is that this one is invoked only when a new child process is being created. In the case of a threaded server or environment (such as Apache 1.3 on Windows), these two callbacks have distinctly different meanings. In strict multi-process Apache environments such as Unix, however, the lines blur.
类似于初始化的回调,child_init钩是提供给那些希望或者需要某种设置的处理模块。这个回调和初始化回调之间的区别在于,在创建一个新的子过程,只有当这一项被调用。在样式匹配的服务器或环境(如在Windows的Apache1.3)的情况下,这两个回调具有明显不同的含义。在严格的多进程Apache环境中,例如Unix,然而,界限模糊。
· The module structure includes a slot for a child_exit callback, which will get invoked when the server is preparing to shut down a child process. Use of this callback is discouraged, however; it is preferable to register a cleanup in the appropriate pool as part of the init or child_init callback routines.
模块结构包括一个child_exit回调的插槽,当服务器准备关闭子进程时会被调用。不鼓励使用这个回调,然而,它是一个更适合注册一个清理合适内存池,这个池在init或child_init的回调程序中涉及到的部分。
Your module will only be invoked for the phases or functions that you have requested by putting routine pointers into the module structure. If you don’t put anything in the child_init slot, for instance, your module whon’t be invoked when the server is doing that processing. 你的模块将只用于调用您通过将常规指针到模块结构要求的阶段或功能。如果你不把任何东西放在child_init位置,例如,当服务器这样处理,我们的模块将不会被调用。
As was mentioned before, in many cases your module configuration record will be handed to your routines as part of their argument list. If you need to locate them yourself, however, you do so with the ap_get_module_config() function described earlier; just give it the pointer to the appropriate list of records and a pointer to your module structure so it can find your record in amongst the others, and that’s it.
就像之前提到的,在许多情况下,您的模块配置记录将会交给你的程序作为参数列表的一部分。如果你需要自己查找他们,,那么,你使用前面所描述ap_get_module_config()函数来做,只要给记录相应的列表的指针和有一个指向你的模块结构的指针,它就可以找到你的记录,就是这样。
The two main list pointers for module records are in the request_rec and server_rec structures, at r->per_dir_config and s->module_config, respectively. There are a couple of additional list pointers as well, but you should stay away from using them unless and until you have both a need and a clear understanding of their use. These are at r->request_config and s->lookup_defaults.
主要记录模块列表的两个指针request_rec 和server_rec分别在r->per_dir_config和s->module_config中,。有一些附加的列表指针,但是你应该远离他们除非你有需要并清楚地了解他们的使用方法。这些都是在r-> request_config和s->lookup_defaults中。
If you end up having to actually add one of your own module configuration record to a list, you can do so with the ap_set_module_config() routine. This is the same routine the server itself uses to manage these lists. 如果你最终不得不添加一个您自己的模块配置记录列表,你可以用ap_get_module_config()函数。这是相同函数,服务器本身也使用它管理这些列表。