nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev
17 years ago
40 | 40 | ngx_test_null(a.elts, ngx_palloc(p, n * s), rc); \ |
41 | 41 | a.nelts = 0; a.size = s; a.nalloc = n; a.pool = p; |
42 | 42 | |
43 | #define ngx_array_push ngx_push_array | |
43 | #define ngx_array_create ngx_create_array | |
44 | #define ngx_array_push ngx_push_array | |
44 | 45 | |
45 | 46 | |
46 | 47 | #endif /* _NGX_ARRAY_H_INCLUDED_ */ |
83 | 83 | #define NGX_OFF_T_LEN sizeof("-9223372036854775808") - 1 |
84 | 84 | |
85 | 85 | |
86 | #if (SOLARIS) | |
87 | ||
88 | /* TODO: auto_conf */ | |
89 | #define NGX_ALIGN (_MAX_ALIGNMENT - 1) /* platform word */ | |
90 | #define NGX_ALIGN_CAST (unsigned long) /* size of the pointer */ | |
91 | ||
92 | #else | |
86 | 93 | |
87 | 94 | /* TODO: auto_conf */ |
88 | 95 | #define NGX_ALIGN (sizeof(unsigned long) - 1) /* platform word */ |
89 | 96 | #define NGX_ALIGN_CAST (unsigned long) /* size of the pointer */ |
97 | ||
98 | #endif | |
90 | 99 | |
91 | 100 | #define ngx_align(p) (char *) ((NGX_ALIGN_CAST p + NGX_ALIGN) & ~NGX_ALIGN) |
92 | 101 |
136 | 136 | |
137 | 137 | lcf = ngx_http_get_module_loc_conf(r, ngx_http_log_module); |
138 | 138 | |
139 | if (lcf->off) { | |
140 | return NGX_OK; | |
141 | } | |
142 | ||
139 | 143 | log = lcf->logs->elts; |
140 | 144 | for (l = 0; l < lcf->logs->nelts; l++) { |
141 | 145 | |
661 | 665 | { |
662 | 666 | ngx_http_log_loc_conf_t *conf; |
663 | 667 | |
664 | ngx_test_null(conf, ngx_pcalloc(cf->pool, sizeof(ngx_http_log_loc_conf_t)), | |
665 | NGX_CONF_ERROR); | |
668 | if (!(conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_log_loc_conf_t)))) { | |
669 | return NGX_CONF_ERROR; | |
670 | } | |
666 | 671 | |
667 | 672 | return conf; |
668 | 673 | } |
679 | 684 | ngx_http_log_main_conf_t *lmcf; |
680 | 685 | |
681 | 686 | if (conf->logs == NULL) { |
687 | ||
688 | if (conf->off) { | |
689 | return NGX_CONF_OK; | |
690 | } | |
691 | ||
682 | 692 | if (prev->logs) { |
683 | 693 | conf->logs = prev->logs; |
684 | 694 | |
685 | 695 | } else { |
686 | 696 | |
687 | conf->logs = ngx_create_array(cf->pool, 2, sizeof(ngx_http_log_t)); | |
697 | if (prev->off) { | |
698 | conf->off = prev->off; | |
699 | return NGX_CONF_OK; | |
700 | } | |
701 | ||
702 | conf->logs = ngx_array_create(cf->pool, 2, sizeof(ngx_http_log_t)); | |
688 | 703 | if (conf->logs == NULL) { |
689 | 704 | return NGX_CONF_ERROR; |
690 | 705 | } |
691 | 706 | |
692 | if (!(log = ngx_push_array(conf->logs))) { | |
707 | if (!(log = ngx_array_push(conf->logs))) { | |
693 | 708 | return NGX_CONF_ERROR; |
694 | 709 | } |
695 | 710 | |
700 | 715 | |
701 | 716 | lmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_log_module); |
702 | 717 | fmt = lmcf->formats.elts; |
718 | ||
703 | 719 | /* the default "combined" format */ |
704 | 720 | log->ops = fmt[0].ops; |
705 | 721 | } |
720 | 736 | ngx_http_log_fmt_t *fmt; |
721 | 737 | ngx_http_log_main_conf_t *lmcf; |
722 | 738 | |
739 | value = cf->args->elts; | |
740 | ||
741 | if (ngx_strcmp(value[1].data, "off") == 0) { | |
742 | llcf->off = 1; | |
743 | return NGX_CONF_OK; | |
744 | } | |
745 | ||
723 | 746 | if (llcf->logs == NULL) { |
724 | if (!(llcf->logs = ngx_create_array(cf->pool, 2, | |
725 | sizeof(ngx_http_log_t)))) { | |
747 | llcf->logs = ngx_array_create(cf->pool, 2, sizeof(ngx_http_log_t)); | |
748 | if (llcf->logs == NULL) { | |
726 | 749 | return NGX_CONF_ERROR; |
727 | 750 | } |
728 | 751 | } |
729 | 752 | |
730 | value = cf->args->elts; | |
731 | 753 | lmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_log_module); |
732 | 754 | |
733 | if (!(log = ngx_push_array(llcf->logs))) { | |
755 | if (!(log = ngx_array_push(llcf->logs))) { | |
734 | 756 | return NGX_CONF_ERROR; |
735 | 757 | } |
736 | 758 |
48 | 48 | |
49 | 49 | typedef struct { |
50 | 50 | ngx_array_t *logs; /* array of ngx_http_log_t */ |
51 | ngx_uint_t off; /* unsigned off:1 */ | |
51 | 52 | } ngx_http_log_loc_conf_t; |
52 | 53 | |
53 | 54 |
96 | 96 | ngx_event_t *rev; |
97 | 97 | ngx_http_log_ctx_t *ctx; |
98 | 98 | |
99 | #if (NGX_STAT_STUB) | |
100 | (*ngx_stat_reading)++; | |
101 | #endif | |
102 | ||
103 | 99 | if (!(ctx = ngx_pcalloc(c->pool, sizeof(ngx_http_log_ctx_t)))) { |
104 | 100 | ngx_http_close_connection(c); |
105 | 101 | return; |
132 | 128 | return; |
133 | 129 | } |
134 | 130 | |
131 | #if (NGX_STAT_STUB) | |
132 | (*ngx_stat_reading)++; | |
133 | #endif | |
134 | ||
135 | 135 | ngx_http_init_request(rev); |
136 | 136 | return; |
137 | 137 | } |
154 | 154 | return; |
155 | 155 | } |
156 | 156 | #endif |
157 | ||
158 | #if (NGX_STAT_STUB) | |
159 | (*ngx_stat_reading)++; | |
160 | #endif | |
161 | ||
157 | 162 | } |
158 | 163 | |
159 | 164 | |
177 | 182 | |
178 | 183 | if (rev->timedout) { |
179 | 184 | ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out"); |
185 | ||
186 | #if (NGX_STAT_STUB) | |
187 | (*ngx_stat_reading)--; | |
188 | #endif | |
189 | ||
180 | 190 | ngx_http_close_connection(c); |
181 | 191 | return; |
182 | 192 | } |
185 | 195 | r = c->data; |
186 | 196 | ngx_memzero(r, sizeof(ngx_http_request_t)); |
187 | 197 | |
198 | #if (NGX_STAT_STUB) | |
199 | (*ngx_stat_reading)++; | |
200 | #endif | |
201 | ||
188 | 202 | } else { |
189 | 203 | if (!(r = ngx_pcalloc(c->pool, sizeof(ngx_http_request_t)))) { |
204 | ||
205 | #if (NGX_STAT_STUB) | |
206 | (*ngx_stat_reading)--; | |
207 | #endif | |
208 | ||
190 | 209 | ngx_http_close_connection(c); |
191 | 210 | return; |
192 | 211 | } |
193 | 212 | |
194 | 213 | c->data = r; |
195 | 214 | } |
215 | ||
216 | #if (NGX_STAT_STUB) | |
217 | r->stat_reading = 1; | |
218 | #endif | |
196 | 219 | |
197 | 220 | c->sent = 0; |
198 | 221 | r->signature = NGX_HTTP_MODULE; |
868 | 891 | |
869 | 892 | #if (NGX_STAT_STUB) |
870 | 893 | (*ngx_stat_reading)--; |
894 | r->stat_reading = 0; | |
871 | 895 | (*ngx_stat_writing)++; |
896 | r->stat_writing = 1; | |
872 | 897 | #endif |
873 | 898 | |
874 | 899 | rev->event_handler = ngx_http_block_read; |
1117 | 1142 | ngx_ssl_set_nosendshut(r->connection->ssl); |
1118 | 1143 | #endif |
1119 | 1144 | } |
1145 | ||
1146 | if (ngx_strstr(r->headers_in.user_agent->value.data, "Opera")) { | |
1147 | r->headers_in.opera = 1; | |
1148 | r->headers_in.msie = 0; | |
1149 | r->headers_in.msie4 = 0; | |
1150 | } | |
1120 | 1151 | } |
1121 | 1152 | |
1122 | 1153 | return NGX_OK; |
1147 | 1178 | } |
1148 | 1179 | |
1149 | 1180 | if (rc == NGX_HTTP_CLIENT_CLOSED_REQUEST || r->closed) { |
1150 | ||
1151 | #if (NGX_STAT_STUB) | |
1152 | (*ngx_stat_writing)--; | |
1153 | #endif | |
1154 | ||
1155 | 1181 | ngx_http_close_request(r, 0); |
1156 | 1182 | ngx_http_close_connection(r->connection); |
1157 | 1183 | return; |
1162 | 1188 | return; |
1163 | 1189 | |
1164 | 1190 | } else if (rc == NGX_ERROR) { |
1165 | ||
1166 | #if (NGX_STAT_STUB) | |
1167 | (*ngx_stat_writing)--; | |
1168 | #endif | |
1169 | ||
1170 | 1191 | ngx_http_close_request(r, 0); |
1171 | 1192 | ngx_http_close_connection(r->connection); |
1172 | 1193 | return; |
1175 | 1196 | ngx_http_set_write_handler(r); |
1176 | 1197 | return; |
1177 | 1198 | } |
1178 | ||
1179 | #if (NGX_STAT_STUB) | |
1180 | (*ngx_stat_writing)--; | |
1181 | #endif | |
1182 | 1199 | |
1183 | 1200 | if (r->connection->read->timer_set) { |
1184 | 1201 | ngx_del_timer(r->connection->read); |
1798 | 1815 | "http request already closed"); |
1799 | 1816 | return; |
1800 | 1817 | } |
1818 | ||
1819 | #if (NGX_STAT_STUB) | |
1820 | if (r->stat_reading) { | |
1821 | (*ngx_stat_reading)--; | |
1822 | } | |
1823 | ||
1824 | if (r->stat_writing) { | |
1825 | (*ngx_stat_writing)--; | |
1826 | } | |
1827 | #endif | |
1801 | 1828 | |
1802 | 1829 | if (error && r->headers_out.status == 0) { |
1803 | 1830 | r->headers_out.status = error; |
147 | 147 | |
148 | 148 | unsigned msie:1; |
149 | 149 | unsigned msie4:1; |
150 | unsigned opera:1; | |
150 | 151 | } ngx_http_headers_in_t; |
151 | 152 | |
152 | 153 | |
306 | 307 | unsigned filter_ssi_need_in_memory:1; |
307 | 308 | unsigned filter_need_temporary:1; |
308 | 309 | unsigned filter_allow_ranges:1; |
310 | ||
311 | #if (NGX_STAT_STUB) | |
312 | unsigned stat_reading:1; | |
313 | unsigned stat_writing:1; | |
314 | #endif | |
309 | 315 | |
310 | 316 | ngx_uint_t headers_n; |
311 | 317 |