2014-03-04 27 views
1

我正在阅读Apache2.2的源代码,并且发现当我使用prefork模块时,它会调用ap_process_connection来处理连接,并在此方法中调用ap_run_pre_connection
说到这里,我找不到ap_run_pre_connectionpre_connection(我找到一个名为AP_DECLARE_HOOK的宏,它在名称pre_connection之前链接了ap_hook_)。
我在哪里可以找到下一步?Apache httpd源代码中的函数ap_run_pre_connection在哪里?

回答

2

您可以通过查找ap_hook_pre_connection找到参与此挂钩的模块。

AP_IMPLEMENT_HOOK_RUN_ALL(INT,pre_connection,(conn_rec * C,void *的CSD),(C,CSD),OK,DECLINED)

AP_IMPLEMENT_HOOK_RUN_ALL意味着多个模块调用ap_hook_pre_connection()将被运行,直到一个错误是返回

/** 
* Implement an Apache core hook that runs until one of the functions 
* returns something other than ok or decline. That return value is 
* then returned from the hook runner. If the hooks run to completion, 
* then ok is returned. Note that if no hook runs it would probably be 
* more correct to return decline, but this currently does not do 
* so. The implementation is called ap_run_<i>name</i>. 

ap_run_pre_connection的实际impl只是一个通过注册函数的链表进行循环的宏。请参阅apr_hooks.h

+0

非常感谢。 – bixiaopeng