comparison src/http/ngx_http_core_module.c @ 59:e8cdc2989cee

nginx-0.0.1-2003-02-06-20:21:13 import
author Igor Sysoev <igor@sysoev.ru>
date Thu, 06 Feb 2003 17:21:13 +0000
parents 058f01f78761
children 50186b49f2ad
comparison
equal deleted inserted replaced
58:6b13b1cadabe 59:e8cdc2989cee
8 8
9 #include <ngx_http.h> 9 #include <ngx_http.h>
10 #include <ngx_http_config.h> 10 #include <ngx_http_config.h>
11 #include <ngx_http_core_module.h> 11 #include <ngx_http_core_module.h>
12 12
13 #if 0 13 /* STUB for r->filter = NGX_HTTP_FILTER_NEED_IN_MEMORY; */
14 #include <ngx_http_write_filter.h>
15 #include <ngx_http_output_filter.h> 14 #include <ngx_http_output_filter.h>
16 #endif 15
17
18 /* STUB */
19 #include <ngx_http_output_filter.h>
20 int ngx_http_static_handler(ngx_http_request_t *r); 16 int ngx_http_static_handler(ngx_http_request_t *r);
21 int ngx_http_proxy_handler(ngx_http_request_t *r); 17 int ngx_http_proxy_handler(ngx_http_request_t *r);
22 /**/ 18 /**/
23 19
24 static int ngx_http_core_index_handler(ngx_http_request_t *r); 20 static int ngx_http_core_index_handler(ngx_http_request_t *r);
102 ngx_http_in_port_t *in_port; 98 ngx_http_in_port_t *in_port;
103 ngx_http_in_addr_t *in_addr; 99 ngx_http_in_addr_t *in_addr;
104 ngx_http_server_name_t *name; 100 ngx_http_server_name_t *name;
105 101
106 r->connection->unexpected_eof = 0; 102 r->connection->unexpected_eof = 0;
107 r->lingering_close = 1; 103
108 r->keepalive = 1; 104 r->lingering_close = 0;
105 r->keepalive = 0;
106
107 #if 0
108 r->filter = NGX_HTTP_FILTER_NEED_IN_MEMORY;
109 #endif
109 110
110 ngx_log_debug(r->connection->log, "servers: %0x" _ r->connection->servers); 111 ngx_log_debug(r->connection->log, "servers: %0x" _ r->connection->servers);
111 112
112 if (r->connection->servers == NULL) { 113 if (r->connection->servers == NULL) {
113 ctx = (ngx_http_conf_ctx_t *) r->connection->ctx; 114 ctx = (ngx_http_conf_ctx_t *) r->connection->ctx;
160 r->loc_conf = ctx->loc_conf; 161 r->loc_conf = ctx->loc_conf;
161 162
162 ngx_log_debug(r->connection->log, "cxt: %08x" _ ctx); 163 ngx_log_debug(r->connection->log, "cxt: %08x" _ ctx);
163 ngx_log_debug(r->connection->log, "srv_conf: %0x" _ r->srv_conf); 164 ngx_log_debug(r->connection->log, "srv_conf: %0x" _ r->srv_conf);
164 ngx_log_debug(r->connection->log, "loc_conf: %0x" _ r->loc_conf); 165 ngx_log_debug(r->connection->log, "loc_conf: %0x" _ r->loc_conf);
165
166
167 #if 1
168 r->filter = NGX_HTTP_FILTER_NEED_IN_MEMORY;
169 #endif
170
171 166
172 /* run translation phase */ 167 /* run translation phase */
173 for (i = 0; ngx_modules[i]; i++) { 168 for (i = 0; ngx_modules[i]; i++) {
174 if (ngx_modules[i]->type != NGX_HTTP_MODULE_TYPE) { 169 if (ngx_modules[i]->type != NGX_HTTP_MODULE_TYPE) {
175 continue; 170 continue;
494 489
495 ngx_destroy_pool(r->pool); 490 ngx_destroy_pool(r->pool);
496 491
497 ngx_log_debug(r->connection->log, "http close"); 492 ngx_log_debug(r->connection->log, "http close");
498 493
499 ngx_del_timer(r->connection->read); 494 if (r->connection->read->timer_set) {
500 ngx_del_timer(r->connection->write); 495 ngx_del_timer(r->connection->read);
496 }
497
498 if (r->connection->write->timer_set) {
499 ngx_del_timer(r->connection->write);
500 }
501 501
502 return NGX_DONE; 502 return NGX_DONE;
503 } 503 }
504 504
505 505
664 cf->ctx = ctx; 664 cf->ctx = ctx;
665 rv = ngx_conf_parse(cf, NULL); 665 rv = ngx_conf_parse(cf, NULL);
666 cf->ctx = prev; 666 cf->ctx = prev;
667 667
668 return rv; 668 return rv;
669 }
670
671
672 int ngx_http_config_modules(ngx_pool_t *pool, ngx_module_t **modules)
673 {
674 int i;
675 ngx_http_module_t *module;
676
677 for (i = 0; modules[i]; i++) {
678 if (modules[i]->type != NGX_HTTP_MODULE_TYPE) {
679 continue;
680 }
681
682 module = (ngx_http_module_t *) modules[i]->ctx;
683 module->index = i;
684 }
685
686 ngx_http_max_module = i;
687
688 #if 0
689 ngx_test_null(ngx_srv_conf,
690 ngx_pcalloc(pool, sizeof(void *) * ngx_http_max_module),
691 NGX_ERROR);
692 ngx_test_null(ngx_loc_conf,
693 ngx_pcalloc(pool, sizeof(void *) * ngx_http_max_module),
694 NGX_ERROR);
695
696 for (i = 0; modules[i]; i++) {
697 if (modules[i]->create_srv_conf)
698 ngx_srv_conf[i] = modules[i]->create_srv_conf(pool);
699
700 if (modules[i]->create_loc_conf)
701 ngx_loc_conf[i] = modules[i]->create_loc_conf(pool);
702 }
703 #endif
704 }
705
706
707 void ngx_http_init_filters(ngx_pool_t *pool, ngx_module_t **modules)
708 {
709 int i;
710 ngx_http_module_t *module;
711 int (*ohf)(ngx_http_request_t *r);
712 int (*obf)(ngx_http_request_t *r, ngx_chain_t *ch);
713
714 ohf = NULL;
715 obf = NULL;
716
717 for (i = 0; modules[i]; i++) {
718 if (modules[i]->type != NGX_HTTP_MODULE_TYPE) {
719 continue;
720 }
721
722 module = (ngx_http_module_t *) modules[i]->ctx;
723
724 if (module->output_header_filter) {
725 module->next_output_header_filter = ohf;
726 ohf = module->output_header_filter;
727 }
728
729 if (module->output_body_filter) {
730 module->next_output_body_filter = obf;
731 obf = module->output_body_filter;
732 }
733 }
734
735 ngx_http_top_header_filter = ohf;
736 } 669 }
737 670
738 671
739 static void *ngx_http_core_create_srv_conf(ngx_pool_t *pool) 672 static void *ngx_http_core_create_srv_conf(ngx_pool_t *pool)
740 { 673 {