Cやってみよう #5
先日の続き
有識者とはタイミングが合わず、今回も独自の視点からみてみましょう!
その前に、apache
に由来する部分を抑えようと思い立ちました。
request_rec
構造体というモノを軽く見てみましょう。
とおもってググったら素晴らしいサイトに出会いました
ここを見れば一発OK!
request_rec
はもう怖くない。
クライアントから送信された、リクエストの中身が見て取れますね!
ではこちら:mod_vhost_maxclients 続けましょう!
140 static int vhost_maxclients_handler(request_rec *r) 141 { 142 int i, j; 143 int vhost_count = 0; 144 int ip_count = 0; 145 char *vhostport; 146 vhost_maxclients_config *scfg = 147 (vhost_maxclients_config *)ap_get_module_config(r->server->module_config, &vhost_maxclients_module);
- 140行目は関数の定義
- 147行目は
ap_get_module_config
で設定を読み込んでいる- 読み込んでるものは、ここ(334〜345行目)に定義されているものであろう(詳細不明)
334 #ifdef __APACHE24__ 335 AP_DECLARE_MODULE(vhost_maxclients) = { 336 #else 337 module AP_MODULE_DECLARE_DATA vhost_maxclients_module = { 338 #endif 339 STANDARD20_MODULE_STUFF, NULL, /* create per-dir config structures */ 340 NULL, /* merge per-dir config structures */ 341 vhost_maxclients_create_server_config, /* create per-server config 342 structures */ 343 vhost_maxclients_create_server_merge_conf, /* merge per-server config structures */ 344 vhost_maxclients_cmds, /* table of config file commands */ 345 vhost_maxclients_register_hooks};
つぎー
149 if (!ap_is_initial_req(r)) { 150 return DECLINED; 151 } 152 153 if (scfg->vhost_maxclients <= 0) { 154 return DECLINED; 155 } 156 157 if (r->hostname == NULL) { 158 return DECLINED; 159 } 160 161 if (!ap_extended_status) { 162 ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, "DEBUG: only used when ExtendedStatus On"); 163 return DECLINED; 164 } 165 166 /* check ignore extesions */ 167 if (check_extension(r->filename, scfg->ignore_extensions)) { 168 return DECLINED; 169 }
- 149行目の
ap_is_initial_req
は以下の判定を行う- 最初のリクエストであれば、true
- リダイレクトだったりした場合は、false
ので、falseの場合は、DECLINED
処理終了(mod_vhost_maxclientsの処理終了)となる
- よってこの辺(149〜169行名)は、変数やリクエストの中身をチェックして、処理できない場合は処理終了としている。
つぎー
171 /* build vhostport name */ 172 vhostport = build_vhostport_name(r);
- 172行目は先週書いた
build_vhostport_name
からhoge.com:80
を取得してる
つぎー。
ここからがこのモジュールのメインの部分であろう。
が、長いので明日に!