2014-03-04 24 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