Klaus Demo nginx / 85cccfb
nginx-0.0.10-2004-09-15-20:00:43 import Igor Sysoev 17 years ago
6 changed file(s) with 93 addition(s) and 27 deletion(s). Raw diff Collapse all Expand all
4040 ngx_test_null(a.elts, ngx_palloc(p, n * s), rc); \
4141 a.nelts = 0; a.size = s; a.nalloc = n; a.pool = p;
4242
43 #define ngx_array_push ngx_push_array
43 #define ngx_array_create ngx_create_array
44 #define ngx_array_push ngx_push_array
4445
4546
4647 #endif /* _NGX_ARRAY_H_INCLUDED_ */
8383 #define NGX_OFF_T_LEN sizeof("-9223372036854775808") - 1
8484
8585
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
8693
8794 /* TODO: auto_conf */
8895 #define NGX_ALIGN (sizeof(unsigned long) - 1) /* platform word */
8996 #define NGX_ALIGN_CAST (unsigned long) /* size of the pointer */
97
98 #endif
9099
91100 #define ngx_align(p) (char *) ((NGX_ALIGN_CAST p + NGX_ALIGN) & ~NGX_ALIGN)
92101
136136
137137 lcf = ngx_http_get_module_loc_conf(r, ngx_http_log_module);
138138
139 if (lcf->off) {
140 return NGX_OK;
141 }
142
139143 log = lcf->logs->elts;
140144 for (l = 0; l < lcf->logs->nelts; l++) {
141145
661665 {
662666 ngx_http_log_loc_conf_t *conf;
663667
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 }
666671
667672 return conf;
668673 }
679684 ngx_http_log_main_conf_t *lmcf;
680685
681686 if (conf->logs == NULL) {
687
688 if (conf->off) {
689 return NGX_CONF_OK;
690 }
691
682692 if (prev->logs) {
683693 conf->logs = prev->logs;
684694
685695 } else {
686696
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));
688703 if (conf->logs == NULL) {
689704 return NGX_CONF_ERROR;
690705 }
691706
692 if (!(log = ngx_push_array(conf->logs))) {
707 if (!(log = ngx_array_push(conf->logs))) {
693708 return NGX_CONF_ERROR;
694709 }
695710
700715
701716 lmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_log_module);
702717 fmt = lmcf->formats.elts;
718
703719 /* the default "combined" format */
704720 log->ops = fmt[0].ops;
705721 }
720736 ngx_http_log_fmt_t *fmt;
721737 ngx_http_log_main_conf_t *lmcf;
722738
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
723746 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) {
726749 return NGX_CONF_ERROR;
727750 }
728751 }
729752
730 value = cf->args->elts;
731753 lmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_log_module);
732754
733 if (!(log = ngx_push_array(llcf->logs))) {
755 if (!(log = ngx_array_push(llcf->logs))) {
734756 return NGX_CONF_ERROR;
735757 }
736758
4848
4949 typedef struct {
5050 ngx_array_t *logs; /* array of ngx_http_log_t */
51 ngx_uint_t off; /* unsigned off:1 */
5152 } ngx_http_log_loc_conf_t;
5253
5354
9696 ngx_event_t *rev;
9797 ngx_http_log_ctx_t *ctx;
9898
99 #if (NGX_STAT_STUB)
100 (*ngx_stat_reading)++;
101 #endif
102
10399 if (!(ctx = ngx_pcalloc(c->pool, sizeof(ngx_http_log_ctx_t)))) {
104100 ngx_http_close_connection(c);
105101 return;
132128 return;
133129 }
134130
131 #if (NGX_STAT_STUB)
132 (*ngx_stat_reading)++;
133 #endif
134
135135 ngx_http_init_request(rev);
136136 return;
137137 }
154154 return;
155155 }
156156 #endif
157
158 #if (NGX_STAT_STUB)
159 (*ngx_stat_reading)++;
160 #endif
161
157162 }
158163
159164
177182
178183 if (rev->timedout) {
179184 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
180190 ngx_http_close_connection(c);
181191 return;
182192 }
185195 r = c->data;
186196 ngx_memzero(r, sizeof(ngx_http_request_t));
187197
198 #if (NGX_STAT_STUB)
199 (*ngx_stat_reading)++;
200 #endif
201
188202 } else {
189203 if (!(r = ngx_pcalloc(c->pool, sizeof(ngx_http_request_t)))) {
204
205 #if (NGX_STAT_STUB)
206 (*ngx_stat_reading)--;
207 #endif
208
190209 ngx_http_close_connection(c);
191210 return;
192211 }
193212
194213 c->data = r;
195214 }
215
216 #if (NGX_STAT_STUB)
217 r->stat_reading = 1;
218 #endif
196219
197220 c->sent = 0;
198221 r->signature = NGX_HTTP_MODULE;
868891
869892 #if (NGX_STAT_STUB)
870893 (*ngx_stat_reading)--;
894 r->stat_reading = 0;
871895 (*ngx_stat_writing)++;
896 r->stat_writing = 1;
872897 #endif
873898
874899 rev->event_handler = ngx_http_block_read;
11171142 ngx_ssl_set_nosendshut(r->connection->ssl);
11181143 #endif
11191144 }
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 }
11201151 }
11211152
11221153 return NGX_OK;
11471178 }
11481179
11491180 if (rc == NGX_HTTP_CLIENT_CLOSED_REQUEST || r->closed) {
1150
1151 #if (NGX_STAT_STUB)
1152 (*ngx_stat_writing)--;
1153 #endif
1154
11551181 ngx_http_close_request(r, 0);
11561182 ngx_http_close_connection(r->connection);
11571183 return;
11621188 return;
11631189
11641190 } else if (rc == NGX_ERROR) {
1165
1166 #if (NGX_STAT_STUB)
1167 (*ngx_stat_writing)--;
1168 #endif
1169
11701191 ngx_http_close_request(r, 0);
11711192 ngx_http_close_connection(r->connection);
11721193 return;
11751196 ngx_http_set_write_handler(r);
11761197 return;
11771198 }
1178
1179 #if (NGX_STAT_STUB)
1180 (*ngx_stat_writing)--;
1181 #endif
11821199
11831200 if (r->connection->read->timer_set) {
11841201 ngx_del_timer(r->connection->read);
17981815 "http request already closed");
17991816 return;
18001817 }
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
18011828
18021829 if (error && r->headers_out.status == 0) {
18031830 r->headers_out.status = error;
147147
148148 unsigned msie:1;
149149 unsigned msie4:1;
150 unsigned opera:1;
150151 } ngx_http_headers_in_t;
151152
152153
306307 unsigned filter_ssi_need_in_memory:1;
307308 unsigned filter_need_temporary:1;
308309 unsigned filter_allow_ranges:1;
310
311 #if (NGX_STAT_STUB)
312 unsigned stat_reading:1;
313 unsigned stat_writing:1;
314 #endif
309315
310316 ngx_uint_t headers_n;
311317