読者です 読者をやめる 読者になる 読者になる

ますたろー日記

大阪から上京して7年。渋谷界隈で頑張ってます。

ap_hook_pre_configが実装されているファイル

apacheソースコードをいくら漁れど、
ap_hook_pre_config関数が実装されている箇所が見つからなくて困っていたのだけど、
ようやく見つかったのでメモです。

学習途上で書いているエントリなので、ひょっとすると間違ってる箇所もあるかもしれません。
もし間違っている箇所があれば、ご指摘いただけるとうれしいです。

以下、httpd-2.2.24のソースコードであることが前提になっています。

ap_hook_pre_config関数というのは何なのかというと、
httpdの実装においてかなりの頻度で呼ばれる関数で、
ドキュメントだと以下のように説明されてます。

> do any setup required prior to processing configuration directives

本処理の前に必要なセットアップ処理を行う関数です。

なお、どうもこの関数の説明は、最新ドキュメントからはなくなっており、
ひょっとすると廃止になってるのかもしれません。
自分は、Googleのキャッシュから上記の説明文を見つけました。

で、この関数ですが、プリプロセッサで宣言・実装されていたのが、
見つけることを困難にさせました。

ap_hook_pre_configの宣言・実装がどこにあるかと言うと、
宣言はinclude/http_config.hに書かれていて、
実装はserver/config.cに書かれています。

これから実装を読んでいこうと思っています。

最後に話が変わりますが、httpd本体のコア系hookは、
support/list_hooks.plというプログラムがあるので、そいつを叩いてやると、
宣言と実装が一覧表示されてコードリーディングの良き助けとなります。

$ perl ./support/list_hooks.pl
access_checker
  declared in ./include/http_request.h
  implemented in ./server/request.c
  type is RUN_ALL
  int access_checker(request_rec *r)

auth_checker
  declared in ./include/http_request.h
  implemented in ./server/request.c
  type is RUN_FIRST
  int auth_checker(request_rec *r)

check_user_id
  declared in ./include/http_request.h
  implemented in ./server/request.c
  type is RUN_FIRST
  int check_user_id(request_rec *r)

child_init
  declared in ./include/http_config.h
  implemented in ./server/config.c
  type is VOID
  void child_init(apr_pool_t *pchild, server_rec *s)

create_connection
  declared in ./include/http_connection.h
  implemented in ./server/connection.c
  type is RUN_FIRST
  conn_rec * create_connection(apr_pool_t *p, server_rec *server, apr_socket_t *csd, long conn_id, void *sbh, apr_bucket_alloc_t *alloc)

create_request
  declared in ./include/http_request.h
  implemented in ./server/request.c
  type is RUN_ALL
  int create_request(request_rec *r)

default_port
  declared in ./include/http_protocol.h
  implemented in ./server/protocol.c
  type is RUN_FIRST
  apr_port_t default_port(const request_rec *r)

error_log
  declared in ./include/http_log.h
  implemented in ./server/log.c
  type is VOID
  void error_log(const char *file, int line, int level, apr_status_t status, const server_rec *s, const request_rec *r, apr_pool_t *pool, const char *errstr)

fatal_exception
  declared in ./include/ap_mpm.h
  implemented in ./server/mpm_common.c
  type is RUN_ALL
  int fatal_exception(ap_exception_info_t *ei)

fixups
  declared in ./include/http_request.h
  implemented in ./server/request.c
  type is RUN_ALL
  int fixups(request_rec *r)

get_mgmt_items
  declared in ./include/http_core.h
  implemented in ./server/core.c
  type is RUN_ALL
  int get_mgmt_items(apr_pool_t *p, const char * val, apr_hash_t *ht)

get_suexec_identity
  declared in ./os/unix/unixd.h
  implemented in ./os/unix/unixd.c
  type is RUN_FIRST
  ap_unix_identity_t * get_suexec_identity(const request_rec *r)

handler
  declared in ./include/http_config.h
  implemented in ./server/config.c
  type is RUN_FIRST
  int handler(request_rec *r)

header_parser
  declared in ./include/http_config.h
  implemented in ./server/config.c
  type is RUN_ALL
  int header_parser(request_rec *r)

http_scheme
  declared in ./include/http_protocol.h
  implemented in ./server/protocol.c
  type is RUN_FIRST
  const char * http_scheme(const request_rec *r)

insert_error_filter
  declared in ./include/http_protocol.h
  implemented in ./modules/http/http_protocol.c
  type is VOID
  void insert_error_filter(request_rec *r)

insert_filter
  declared in ./include/http_request.h
  implemented in ./server/request.c
  type is VOID
  void insert_filter(request_rec *r)

log_transaction
  declared in ./include/http_protocol.h
  implemented in ./server/protocol.c
  type is RUN_ALL
  int log_transaction(request_rec *r)

map_to_storage
  declared in ./include/http_request.h
  implemented in ./server/request.c
  type is RUN_FIRST
  int map_to_storage(request_rec *r)

monitor
  declared in ./include/mpm_common.h
  implemented in ./server/mpm_common.c
  type is RUN_ALL
  int monitor(apr_pool_t *p)

open_logs
  declared in ./include/http_config.h
  implemented in ./server/config.c
  type is RUN_ALL
  int open_logs(apr_pool_t *pconf,apr_pool_t *plog, apr_pool_t *ptemp,server_rec *s)

optional_fn_retrieve
  declared in ./include/http_config.h
  implemented in ./server/config.c
  type is VOID
  void optional_fn_retrieve(void)

optional_hook_test
  declared in ./modules/test/mod_optional_hook_export.h
  implemented in ./modules/test/mod_optional_hook_export.c
  type is OPTIONAL RUN_ALL
  int optional_hook_test(const char *)

post_config
  declared in ./include/http_config.h
  implemented in ./server/config.c
  type is RUN_ALL
  int post_config(apr_pool_t *pconf,apr_pool_t *plog, apr_pool_t *ptemp,server_rec *s)

post_read_request
  declared in ./include/http_protocol.h
  implemented in ./server/protocol.c
  type is RUN_ALL
  int post_read_request(request_rec *r)

pre_config
  declared in ./include/http_config.h
  implemented in ./server/config.c
  type is RUN_ALL
  int pre_config(apr_pool_t *pconf,apr_pool_t *plog, apr_pool_t *ptemp)

pre_connection
  declared in ./include/http_connection.h
  implemented in ./server/connection.c
  type is RUN_ALL
  int pre_connection(conn_rec *c, void *csd)

pre_mpm
  declared in ./include/scoreboard.h
  implemented in ./server/scoreboard.c
  type is RUN_ALL
  int pre_mpm(apr_pool_t *p, ap_scoreboard_e sb_type)

process_connection
  declared in ./include/http_connection.h
  implemented in ./server/connection.c
  type is RUN_FIRST
  int process_connection(conn_rec *c)

quick_handler
  declared in ./include/http_config.h
  implemented in ./server/config.c
  type is RUN_FIRST
  int quick_handler(request_rec *r, int lookup_uri)

test_config
  declared in ./include/http_config.h
  implemented in ./server/config.c
  type is VOID
  void test_config(apr_pool_t *pconf, server_rec *s)

translate_name
  declared in ./include/http_request.h
  implemented in ./server/request.c
  type is RUN_FIRST
  int translate_name(request_rec *r)

type_checker
  declared in ./include/http_request.h
  implemented in ./server/request.c
  type is RUN_FIRST
  int type_checker(request_rec *r)