Klaus Demo nginx / 2d3f3f6
fix English grammar Igor Sysoev 14 years ago
28 changed file(s) with 149 addition(s) and 149 deletion(s). Raw diff Collapse all Expand all
2727 unsigned len:29;
2828
2929 unsigned valid:1;
30 unsigned no_cachable:1;
30 unsigned no_cacheable:1;
3131 unsigned not_found:1;
3232
3333 u_char *data;
88 #include <ngx_event.h>
99
1010
11 static ngx_int_t ngx_event_busy_lock_look_cachable(ngx_event_busy_lock_t *bl,
11 static ngx_int_t ngx_event_busy_lock_look_cacheable(ngx_event_busy_lock_t *bl,
1212 ngx_event_busy_lock_ctx_t *ctx);
1313 static void ngx_event_busy_lock_handler(ngx_event_t *ev);
1414 static void ngx_event_busy_lock_posted_handler(ngx_event_t *ev);
6464
6565
6666 ngx_int_t
67 ngx_event_busy_lock_cachable(ngx_event_busy_lock_t *bl,
67 ngx_event_busy_lock_cacheable(ngx_event_busy_lock_t *bl,
6868 ngx_event_busy_lock_ctx_t *ctx)
6969 {
7070 ngx_int_t rc;
7171
7272 ngx_mutex_lock(bl->mutex);
7373
74 rc = ngx_event_busy_lock_look_cachable(bl, ctx);
74 rc = ngx_event_busy_lock_look_cacheable(bl, ctx);
7575
7676 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, ctx->event->log, 0,
7777 "event busy lock: %d w:%d mw:%d",
200200
201201
202202 static ngx_int_t
203 ngx_event_busy_lock_look_cachable(ngx_event_busy_lock_t *bl,
203 ngx_event_busy_lock_look_cacheable(ngx_event_busy_lock_t *bl,
204204 ngx_event_busy_lock_ctx_t *ctx)
205205 {
206206 ngx_int_t free;
207 ngx_uint_t i, bit, cachable, mask;
207 ngx_uint_t i, bit, cacheable, mask;
208208
209209 bit = 0;
210 cachable = 0;
210 cacheable = 0;
211211 free = -1;
212212
213213 #if (NGX_SUPPRESS_WARN)
226226 ctx->slot = i;
227227 return NGX_AGAIN;
228228 }
229 cachable++;
229 cacheable++;
230230
231231 } else if (free == -1) {
232232 free = i;
233233 }
234234
235 if (cachable == bl->cachable) {
236 if (free == -1 && cachable < bl->max_busy) {
235 if (cacheable == bl->cacheable) {
236 if (free == -1 && cacheable < bl->max_busy) {
237237 free = i + 1;
238238 }
239239
258258 bl->md5_mask[free / 8] |= 1 << (free & 7);
259259 ctx->slot = free;
260260
261 bl->cachable++;
261 bl->cacheable++;
262262 bl->busy++;
263263
264264 return NGX_OK;
3333 typedef struct {
3434 u_char *md5_mask;
3535 char *md5;
36 ngx_uint_t cachable;
36 ngx_uint_t cacheable;
3737
3838 ngx_uint_t busy;
3939 ngx_uint_t max_busy;
5252
5353 ngx_int_t ngx_event_busy_lock(ngx_event_busy_lock_t *bl,
5454 ngx_event_busy_lock_ctx_t *ctx);
55 ngx_int_t ngx_event_busy_lock_cachable(ngx_event_busy_lock_t *bl,
55 ngx_int_t ngx_event_busy_lock_cacheable(ngx_event_busy_lock_t *bl,
5656 ngx_event_busy_lock_ctx_t *ctx);
5757 void ngx_event_busy_unlock(ngx_event_busy_lock_t *bl,
5858 ngx_event_busy_lock_ctx_t *ctx);
191191 chain->buf = b;
192192 chain->next = NULL;
193193
194 } else if (!p->cachable
194 } else if (!p->cacheable
195195 && p->downstream->data == p->output_ctx
196196 && p->downstream->write->ready
197197 && !p->downstream->write->delayed)
208208
209209 break;
210210
211 } else if (p->cachable
211 } else if (p->cacheable
212212 || p->temp_file->offset < p->max_temp_file_size)
213213 {
214214
405405 }
406406 }
407407
408 if (p->cachable && p->in) {
408 if (p->cacheable && p->in) {
409409 if (ngx_event_pipe_write_chain_to_temp_file(p) == NGX_ABORT) {
410410 return NGX_ABORT;
411411 }
541541
542542 ngx_event_pipe_free_shadow_raw_buf(&p->free_raw_bufs, cl->buf);
543543
544 } else if (!p->cachable && p->in) {
544 } else if (!p->cacheable && p->in) {
545545 cl = p->in;
546546
547547 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, p->log, 0,
611611 for (cl = p->free; cl; cl = cl->next) {
612612
613613 if (cl->buf->temp_file) {
614 if (p->cachable || !p->cyclic_temp_file) {
614 if (p->cacheable || !p->cyclic_temp_file) {
615615 continue;
616616 }
617617
658658 out = p->in;
659659 }
660660
661 if (!p->cachable) {
661 if (!p->cacheable) {
662662
663663 size = 0;
664664 cl = out;
4646 void *output_ctx;
4747
4848 unsigned read:1;
49 unsigned cachable:1;
49 unsigned cacheable:1;
5050 unsigned single_buf:1;
5151 unsigned free_bufs:1;
5252 unsigned upstream_done:1;
396396
397397 for (var = ngx_http_browsers; var->name.len; var++) {
398398
399 v = ngx_http_add_variable(cf, &var->name, NGX_HTTP_VAR_CHANGABLE);
399 v = ngx_http_add_variable(cf, &var->name, NGX_HTTP_VAR_CHANGEABLE);
400400 if (v == NULL) {
401401 return NGX_ERROR;
402402 }
672672
673673 bcf->modern_browser_value->len = value[1].len;
674674 bcf->modern_browser_value->valid = 1;
675 bcf->modern_browser_value->no_cachable = 0;
675 bcf->modern_browser_value->no_cacheable = 0;
676676 bcf->modern_browser_value->not_found = 0;
677677 bcf->modern_browser_value->data = value[1].data;
678678
697697
698698 bcf->ancient_browser_value->len = value[1].len;
699699 bcf->ancient_browser_value->valid = 1;
700 bcf->ancient_browser_value->no_cachable = 0;
700 bcf->ancient_browser_value->no_cacheable = 0;
701701 bcf->ancient_browser_value->not_found = 0;
702702 bcf->ancient_browser_value->data = value[1].data;
703703
504504 if (flcf->params_len) {
505505 ngx_memzero(&le, sizeof(ngx_http_script_engine_t));
506506
507 ngx_http_script_flush_no_cachable_variables(r, flcf->flushes);
507 ngx_http_script_flush_no_cacheable_variables(r, flcf->flushes);
508508 le.flushed = 1;
509509
510510 le.ip = flcf->params_len->elts;
11851185
11861186 u->state->status = u->headers_in.status_n;
11871187 #if 0
1188 if (u->cachable) {
1189 u->cachable = ngx_http_upstream_is_cachable(r);
1188 if (u->cacheable) {
1189 u->cacheable = ngx_http_upstream_is_cacheable(r);
11901190 }
11911191 #endif
11921192
16091609 ngx_http_variable_t *var;
16101610
16111611 var = ngx_http_add_variable(cf, &ngx_http_fastcgi_script_name,
1612 NGX_HTTP_VAR_NOHASH|NGX_HTTP_VAR_NOCACHABLE);
1612 NGX_HTTP_VAR_NOHASH|NGX_HTTP_VAR_NOCACHEABLE);
16131613 if (var == NULL) {
16141614 return NGX_ERROR;
16151615 }
21032103
21042104 if (r->uri.len) {
21052105 v->valid = 1;
2106 v->no_cachable = 0;
2106 v->no_cacheable = 0;
21072107 v->not_found = 0;
21082108
21092109 flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module);
21272127 } else {
21282128 v->len = 0;
21292129 v->valid = 1;
2130 v->no_cachable = 0;
2130 v->no_cacheable = 0;
21312131 v->not_found = 0;
21322132 v->data = NULL;
21332133
115115 name.data++;
116116 }
117117
118 var = ngx_http_add_variable(cf, &name, NGX_HTTP_VAR_CHANGABLE);
118 var = ngx_http_add_variable(cf, &name, NGX_HTTP_VAR_CHANGEABLE);
119119 if (var == NULL) {
120120 return NGX_CONF_ERROR;
121121 }
256256 }
257257
258258 var->valid = 1;
259 var->no_cachable = 0;
259 var->no_cacheable = 0;
260260 var->not_found = 0;
261261
262262 v = ngx_array_push(&ctx->values);
939939 ngx_http_gzip_ctx_t *ctx;
940940
941941 v->valid = 1;
942 v->no_cachable = 0;
942 v->no_cacheable = 0;
943943 v->not_found = 0;
944944
945945 ctx = ngx_http_get_module_ctx(r, ngx_http_gzip_filter_module);
220220 name.len--;
221221 name.data++;
222222
223 var = ngx_http_add_variable(cf, &name, NGX_HTTP_VAR_CHANGABLE);
223 var = ngx_http_add_variable(cf, &name, NGX_HTTP_VAR_CHANGEABLE);
224224 if (var == NULL) {
225225 return NGX_CONF_ERROR;
226226 }
429429 }
430430
431431 var->valid = 1;
432 var->no_cachable = 0;
432 var->no_cacheable = 0;
433433 var->not_found = 0;
434434
435435 vp = ngx_array_push(&ctx->values_hash[key]);
419419 static ngx_http_variable_t ngx_http_proxy_vars[] = {
420420
421421 { ngx_string("proxy_host"), NULL, ngx_http_proxy_host_variable, 0,
422 NGX_HTTP_VAR_CHANGABLE|NGX_HTTP_VAR_NOHASH, 0 },
422 NGX_HTTP_VAR_CHANGEABLE|NGX_HTTP_VAR_NOHASH, 0 },
423423
424424 { ngx_string("proxy_port"), NULL, ngx_http_proxy_port_variable, 0,
425 NGX_HTTP_VAR_CHANGABLE|NGX_HTTP_VAR_NOHASH, 0 },
425 NGX_HTTP_VAR_CHANGEABLE|NGX_HTTP_VAR_NOHASH, 0 },
426426
427427 { ngx_string("proxy_add_x_forwarded_for"), NULL,
428428 ngx_http_proxy_add_x_forwarded_for_variable, 0, NGX_HTTP_VAR_NOHASH, 0 },
560560 len += r->uri.len - loc_len + escape + sizeof("?") - 1 + r->args.len;
561561 }
562562
563 ngx_http_script_flush_no_cachable_variables(r, plcf->flushes);
563 ngx_http_script_flush_no_cacheable_variables(r, plcf->flushes);
564564
565565 if (plcf->body_set_len) {
566566 le.ip = plcf->body_set_len->elts;
12481248
12491249 v->len = plcf->host_header.len;
12501250 v->valid = 1;
1251 v->no_cachable = 0;
1251 v->no_cacheable = 0;
12521252 v->not_found = 0;
12531253 v->data = plcf->host_header.data;
12541254
12661266
12671267 v->len = plcf->port.len;
12681268 v->valid = 1;
1269 v->no_cachable = 0;
1269 v->no_cacheable = 0;
12701270 v->not_found = 0;
12711271 v->data = plcf->port.data;
12721272
12811281 u_char *p;
12821282
12831283 v->valid = 1;
1284 v->no_cachable = 0;
1284 v->no_cacheable = 0;
12851285 v->not_found = 0;
12861286
12871287 if (r->headers_in.x_forwarded_for == NULL) {
13251325 }
13261326
13271327 v->valid = 1;
1328 v->no_cachable = 0;
1328 v->no_cacheable = 0;
13291329 v->not_found = 0;
13301330
13311331 v->data = ngx_palloc(r->connection->pool, NGX_SIZE_T_LEN);
366366 name.data = (u_char *) "invalid_referer";
367367
368368 var = ngx_http_add_variable(cf, &name,
369 NGX_HTTP_VAR_CHANGABLE|NGX_HTTP_VAR_NOHASH);
369 NGX_HTTP_VAR_CHANGEABLE|NGX_HTTP_VAR_NOHASH);
370370 if (var == NULL) {
371371 return NGX_CONF_ERROR;
372372 }
923923 value[1].len--;
924924 value[1].data++;
925925
926 v = ngx_http_add_variable(cf, &value[1], NGX_HTTP_VAR_CHANGABLE);
926 v = ngx_http_add_variable(cf, &value[1], NGX_HTTP_VAR_CHANGEABLE);
927927 if (v == NULL) {
928928 return NGX_CONF_ERROR;
929929 }
302302 static ngx_http_variable_t ngx_http_ssi_vars[] = {
303303
304304 { ngx_string("date_local"), NULL, ngx_http_ssi_date_gmt_local_variable, 0,
305 NGX_HTTP_VAR_NOCACHABLE, 0 },
305 NGX_HTTP_VAR_NOCACHEABLE, 0 },
306306
307307 { ngx_string("date_gmt"), NULL, ngx_http_ssi_date_gmt_local_variable, 1,
308 NGX_HTTP_VAR_NOCACHABLE, 0 },
308 NGX_HTTP_VAR_NOCACHEABLE, 0 },
309309
310310 { ngx_null_string, NULL, NULL, 0, 0, 0 }
311311 };
26402640 char buf[NGX_HTTP_SSI_DATE_LEN];
26412641
26422642 v->valid = 1;
2643 v->no_cachable = 0;
2643 v->no_cacheable = 0;
26442644 v->not_found = 0;
26452645
26462646 tp = ngx_timeofday();
169169 static ngx_http_variable_t ngx_http_ssl_vars[] = {
170170
171171 { ngx_string("ssl_protocol"), NULL, ngx_http_ssl_static_variable,
172 (uintptr_t) ngx_ssl_get_protocol, NGX_HTTP_VAR_CHANGABLE, 0 },
172 (uintptr_t) ngx_ssl_get_protocol, NGX_HTTP_VAR_CHANGEABLE, 0 },
173173
174174 { ngx_string("ssl_cipher"), NULL, ngx_http_ssl_static_variable,
175 (uintptr_t) ngx_ssl_get_cipher_name, NGX_HTTP_VAR_CHANGABLE, 0 },
175 (uintptr_t) ngx_ssl_get_cipher_name, NGX_HTTP_VAR_CHANGEABLE, 0 },
176176
177177 { ngx_string("ssl_client_s_dn"), NULL, ngx_http_ssl_variable,
178 (uintptr_t) ngx_ssl_get_subject_dn, NGX_HTTP_VAR_CHANGABLE, 0 },
178 (uintptr_t) ngx_ssl_get_subject_dn, NGX_HTTP_VAR_CHANGEABLE, 0 },
179179
180180 { ngx_string("ssl_client_i_dn"), NULL, ngx_http_ssl_variable,
181 (uintptr_t) ngx_ssl_get_issuer_dn, NGX_HTTP_VAR_CHANGABLE, 0 },
181 (uintptr_t) ngx_ssl_get_issuer_dn, NGX_HTTP_VAR_CHANGEABLE, 0 },
182182
183183 { ngx_string("ssl_client_serial"), NULL, ngx_http_ssl_variable,
184 (uintptr_t) ngx_ssl_get_serial_number, NGX_HTTP_VAR_CHANGABLE, 0 },
184 (uintptr_t) ngx_ssl_get_serial_number, NGX_HTTP_VAR_CHANGEABLE, 0 },
185185
186186 { ngx_null_string, NULL, NULL, 0, 0, 0 }
187187 };
209209
210210 v->len = len;
211211 v->valid = 1;
212 v->no_cachable = 0;
212 v->no_cacheable = 0;
213213 v->not_found = 0;
214214
215215 return NGX_OK;
240240
241241 if (v->len) {
242242 v->valid = 1;
243 v->no_cachable = 0;
243 v->no_cacheable = 0;
244244 v->not_found = 0;
245245
246246 return NGX_OK;
492492 }
493493
494494 v->valid = 1;
495 v->no_cachable = 0;
495 v->no_cacheable = 0;
496496 v->not_found = 0;
497497
498498 ngx_sprintf(v->data, "%V=%08XD%08XD%08XD%08XD",
911911 if (value) {
912912 vv->len = val.len;
913913 vv->valid = 1;
914 vv->no_cachable = 0;
914 vv->no_cacheable = 0;
915915 vv->not_found = 0;
916916 vv->data = val.data;
917917
335335 if (value.data) {
336336 v->len = value.len;
337337 v->valid = 1;
338 v->no_cachable = 0;
338 v->no_cacheable = 0;
339339 v->not_found = 0;
340340 v->data = value.data;
341341
953953 value[1].len--;
954954 value[1].data++;
955955
956 v = ngx_http_add_variable(cf, &value[1], NGX_HTTP_VAR_CHANGABLE);
956 v = ngx_http_add_variable(cf, &value[1], NGX_HTTP_VAR_CHANGEABLE);
957957 if (v == NULL) {
958958 return NGX_CONF_ERROR;
959959 }
99
1010
1111
12 static int ngx_http_busy_lock_look_cachable(ngx_http_busy_lock_t *bl,
13 ngx_http_busy_lock_ctx_t *bc,
14 int lock);
12 static int ngx_http_busy_lock_look_cacheable(ngx_http_busy_lock_t *bl,
13 ngx_http_busy_lock_ctx_t *bc,
14 int lock);
1515
1616
1717 int ngx_http_busy_lock(ngx_http_busy_lock_t *bl, ngx_http_busy_lock_ctx_t *bc)
5959 }
6060
6161
62 int ngx_http_busy_lock_cachable(ngx_http_busy_lock_t *bl,
63 ngx_http_busy_lock_ctx_t *bc, int lock)
62 int ngx_http_busy_lock_cacheable(ngx_http_busy_lock_t *bl,
63 ngx_http_busy_lock_ctx_t *bc, int lock)
6464 {
6565 int rc;
6666
67 rc = ngx_http_busy_lock_look_cachable(bl, bc, lock);
67 rc = ngx_http_busy_lock_look_cacheable(bl, bc, lock);
6868
6969 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, bc->event->log, 0,
7070 "http busylock: %d w:%d mw::%d",
120120
121121 if (bl->md5) {
122122 bl->md5_mask[bc->slot / 8] &= ~(1 << (bc->slot & 7));
123 bl->cachable--;
123 bl->cacheable--;
124124 }
125125
126126 bl->busy--;
127127 }
128128
129129
130 static int ngx_http_busy_lock_look_cachable(ngx_http_busy_lock_t *bl,
131 ngx_http_busy_lock_ctx_t *bc,
132 int lock)
133 {
134 int i, b, cachable, free;
130 static int ngx_http_busy_lock_look_cacheable(ngx_http_busy_lock_t *bl,
131 ngx_http_busy_lock_ctx_t *bc,
132 int lock)
133 {
134 int i, b, cacheable, free;
135135 u_int mask;
136136
137137 b = 0;
138 cachable = 0;
138 cacheable = 0;
139139 free = -1;
140140
141141 #if (NGX_SUPPRESS_WARN)
152152 if (ngx_memcmp(&bl->md5[i * 16], bc->md5, 16) == 0) {
153153 return NGX_AGAIN;
154154 }
155 cachable++;
155 cacheable++;
156156
157157 } else if (free == -1) {
158158 free = i;
159159 }
160160
161161 #if 1
162 if (cachable == bl->cachable) {
163 if (free == -1 && cachable < bl->max_busy) {
162 if (cacheable == bl->cacheable) {
163 if (free == -1 && cacheable < bl->max_busy) {
164164 free = i + 1;
165165 }
166166
185185 bl->md5_mask[free / 8] |= 1 << (free & 7);
186186 bc->slot = free;
187187
188 bl->cachable++;
188 bl->cacheable++;
189189 bl->busy++;
190190 }
191191
1616 typedef struct {
1717 u_char *md5_mask;
1818 char *md5;
19 int cachable;
19 int cacheable;
2020
2121 int busy;
2222 int max_busy;
4040
4141
4242 int ngx_http_busy_lock(ngx_http_busy_lock_t *bl, ngx_http_busy_lock_ctx_t *bc);
43 int ngx_http_busy_lock_cachable(ngx_http_busy_lock_t *bl,
44 ngx_http_busy_lock_ctx_t *bc, int lock);
43 int ngx_http_busy_lock_cacheable(ngx_http_busy_lock_t *bl,
44 ngx_http_busy_lock_ctx_t *bc, int lock);
4545 void ngx_http_busy_unlock(ngx_http_busy_lock_t *bl,
4646 ngx_http_busy_lock_ctx_t *bc);
4747
448448 unsigned limit_zone_set:1;
449449
450450 #if 0
451 unsigned cachable:1;
451 unsigned cacheable:1;
452452 #endif
453453
454454 unsigned pipeline:1;
313313 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
314314
315315 for (i = 0; i < cmcf->variables.nelts; i++) {
316 if (r->variables[i].no_cachable) {
316 if (r->variables[i].no_cacheable) {
317317 r->variables[i].valid = 0;
318318 r->variables[i].not_found = 0;
319319 }
350350
351351
352352 void
353 ngx_http_script_flush_no_cachable_variables(ngx_http_request_t *r,
353 ngx_http_script_flush_no_cacheable_variables(ngx_http_request_t *r,
354354 ngx_array_t *indices)
355355 {
356356 ngx_uint_t n, *index;
358358 if (indices) {
359359 index = indices->elts;
360360 for (n = 0; n < indices->nelts; n++) {
361 if (r->variables[index[n]].no_cachable) {
361 if (r->variables[index[n]].no_cacheable) {
362362 r->variables[index[n]].valid = 0;
363363 r->variables[index[n]].not_found = 0;
364364 }
11511151
11521152 r->variables[code->index].len = e->sp->len;
11531153 r->variables[code->index].valid = 1;
1154 r->variables[code->index].no_cachable = 0;
1154 r->variables[code->index].no_cacheable = 0;
11551155 r->variables[code->index].not_found = 0;
11561156 r->variables[code->index].data = e->sp->data;
11571157 }
180180 ngx_int_t ngx_http_script_compile(ngx_http_script_compile_t *sc);
181181 u_char *ngx_http_script_run(ngx_http_request_t *r, ngx_str_t *value,
182182 void *code_lengths, size_t reserved, void *code_values);
183 void ngx_http_script_flush_no_cachable_variables(ngx_http_request_t *r,
183 void ngx_http_script_flush_no_cacheable_variables(ngx_http_request_t *r,
184184 ngx_array_t *indices);
185185
186186 void *ngx_http_script_start_code(ngx_pool_t *pool, ngx_array_t **codes,
433433 ev->error = 1;
434434 }
435435
436 if (!u->cachable && !u->store && u->peer.connection) {
436 if (!u->cacheable && !u->store && u->peer.connection) {
437437 ngx_log_error(NGX_LOG_INFO, ev->log, ev->kq_errno,
438438 "kevent() reported that client closed prematurely "
439439 "connection, so upstream connection is closed too");
499499 ev->eof = 1;
500500 c->error = 1;
501501
502 if (!u->cachable && !u->store && u->peer.connection) {
502 if (!u->cacheable && !u->store && u->peer.connection) {
503503 ngx_log_error(NGX_LOG_INFO, ev->log, err,
504504 "client closed prematurely connection, "
505505 "so upstream connection is closed too");
15121512 }
15131513 }
15141514
1515 if (u->cachable) {
1515 if (u->cacheable) {
15161516 header = (ngx_http_cache_header_t *) u->buffer->start;
15171517
15181518 header->expires = u->cache->ctx.expires;
15401540 p->pool = r->pool;
15411541 p->log = c->log;
15421542
1543 p->cachable = u->cachable || u->store;
1543 p->cacheable = u->cacheable || u->store;
15441544
15451545 p->temp_file = ngx_pcalloc(r->pool, sizeof(ngx_temp_file_t));
15461546 if (p->temp_file == NULL) {
15531553 p->temp_file->path = u->conf->temp_path;
15541554 p->temp_file->pool = r->pool;
15551555
1556 if (u->cachable || u->store) {
1556 if (u->cacheable || u->store) {
15571557 p->temp_file->persistent = 1;
15581558
15591559 } else {
15771577
15781578 p->preread_size = u->buffer.last - u->buffer.pos;
15791579
1580 if (u->cachable) {
1580 if (u->cacheable) {
15811581
15821582 p->buf_to_file = ngx_calloc_buf(r->pool);
15831583 if (p->buf_to_file == NULL) {
19541954
19551955 #if (NGX_HTTP_FILE_CACHE)
19561956
1957 if (p->upstream_done && u->cachable) {
1957 if (p->upstream_done && u->cacheable) {
19581958 if (ngx_http_cache_update(r) == NGX_ERROR) {
19591959 ngx_http_busy_unlock(u->conf->busy_lock, &u->busy_lock);
19601960 ngx_http_upstream_finalize_request(r, u, 0);
19611961 return;
19621962 }
19631963
1964 } else if (p->upstream_eof && u->cachable) {
1964 } else if (p->upstream_eof && u->cacheable) {
19651965
19661966 /* TODO: check length & update cache */
19671967
19891989 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0,
19901990 "http upstream downstream error");
19911991
1992 if (!u->cachable && u->peer.connection) {
1992 if (!u->cacheable && u->peer.connection) {
19931993 ngx_http_upstream_finalize_request(r, u, 0);
19941994 }
19951995 }
27132713 ngx_http_upstream_state_t *state;
27142714
27152715 v->valid = 1;
2716 v->no_cachable = 0;
2716 v->no_cacheable = 0;
27172717 v->not_found = 0;
27182718
27192719 if (r->upstream_states == NULL || r->upstream_states->nelts == 0) {
27842784 ngx_http_upstream_state_t *state;
27852785
27862786 v->valid = 1;
2787 v->no_cachable = 0;
2787 v->no_cacheable = 0;
27882788 v->not_found = 0;
27892789
27902790 if (r->upstream_states == NULL || r->upstream_states->nelts == 0) {
28502850 ngx_http_upstream_state_t *state;
28512851
28522852 v->valid = 1;
2853 v->no_cachable = 0;
2853 v->no_cacheable = 0;
28542854 v->not_found = 0;
28552855
28562856 if (r->upstream_states == NULL || r->upstream_states->nelts == 0) {
243243 ngx_http_cleanup_pt *cleanup;
244244
245245 unsigned store:1;
246 unsigned cachable:1;
246 unsigned cacheable:1;
247247 unsigned accel:1;
248248
249249 unsigned buffering:1;
142142
143143 { ngx_string("uri"), NULL, ngx_http_variable_request,
144144 offsetof(ngx_http_request_t, uri),
145 NGX_HTTP_VAR_NOCACHABLE, 0 },
145 NGX_HTTP_VAR_NOCACHEABLE, 0 },
146146
147147 { ngx_string("document_uri"), NULL, ngx_http_variable_request,
148148 offsetof(ngx_http_request_t, uri),
149 NGX_HTTP_VAR_NOCACHABLE, 0 },
149 NGX_HTTP_VAR_NOCACHEABLE, 0 },
150150
151151 { ngx_string("request"), NULL, ngx_http_variable_request,
152152 offsetof(ngx_http_request_t, request_line), 0, 0 },
153153
154154 { ngx_string("document_root"), NULL,
155 ngx_http_variable_document_root, 0, NGX_HTTP_VAR_NOCACHABLE, 0 },
155 ngx_http_variable_document_root, 0, NGX_HTTP_VAR_NOCACHEABLE, 0 },
156156
157157 { ngx_string("query_string"), NULL, ngx_http_variable_request,
158158 offsetof(ngx_http_request_t, args),
159 NGX_HTTP_VAR_NOCACHABLE, 0 },
159 NGX_HTTP_VAR_NOCACHEABLE, 0 },
160160
161161 { ngx_string("args"),
162162 ngx_http_variable_request_set,
163163 ngx_http_variable_request,
164164 offsetof(ngx_http_request_t, args),
165 NGX_HTTP_VAR_CHANGABLE|NGX_HTTP_VAR_NOCACHABLE, 0 },
165 NGX_HTTP_VAR_CHANGEABLE|NGX_HTTP_VAR_NOCACHEABLE, 0 },
166166
167167 { ngx_string("is_args"), NULL, ngx_http_variable_is_args,
168 0, NGX_HTTP_VAR_NOCACHABLE, 0 },
168 0, NGX_HTTP_VAR_NOCACHEABLE, 0 },
169169
170170 { ngx_string("request_filename"), NULL,
171171 ngx_http_variable_request_filename, 0,
172 NGX_HTTP_VAR_NOCACHABLE, 0 },
172 NGX_HTTP_VAR_NOCACHEABLE, 0 },
173173
174174 { ngx_string("server_name"), NULL, ngx_http_variable_request,
175175 offsetof(ngx_http_request_t, server_name), 0, 0 },
214214 { ngx_string("limit_rate"), ngx_http_variable_request_set_size,
215215 ngx_http_variable_request,
216216 offsetof(ngx_http_request_t, limit_rate),
217 NGX_HTTP_VAR_CHANGABLE|NGX_HTTP_VAR_NOCACHABLE, 0 },
217 NGX_HTTP_VAR_CHANGEABLE|NGX_HTTP_VAR_NOCACHEABLE, 0 },
218218
219219 { ngx_string("nginx_version"), NULL, ngx_http_variable_nginx_version,
220220 0, 0, 0 },
250250
251251 v = key[i].value;
252252
253 if (!(v->flags & NGX_HTTP_VAR_CHANGABLE)) {
253 if (!(v->flags & NGX_HTTP_VAR_CHANGEABLE)) {
254254 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
255255 "the duplicate \"%V\" variable", name);
256256 return NULL;
374374 if (v[index].get_handler(r, &r->variables[index], v[index].data)
375375 == NGX_OK)
376376 {
377 if (v[index].flags & NGX_HTTP_VAR_NOCACHABLE) {
378 r->variables[index].no_cachable = 1;
377 if (v[index].flags & NGX_HTTP_VAR_NOCACHEABLE) {
378 r->variables[index].no_cacheable = 1;
379379 }
380380
381381 return &r->variables[index];
396396 v = &r->variables[index];
397397
398398 if (v->valid) {
399 if (!v->no_cachable) {
399 if (!v->no_cacheable) {
400400 return v;
401401 }
402402
496496 if (s->data) {
497497 v->len = s->len;
498498 v->valid = 1;
499 v->no_cachable = 0;
499 v->no_cacheable = 0;
500500 v->not_found = 0;
501501 v->data = s->data;
502502
558558 if (h) {
559559 v->len = h->value.len;
560560 v->valid = 1;
561 v->no_cachable = 0;
561 v->no_cacheable = 0;
562562 v->not_found = 0;
563563 v->data = h->value.data;
564564
590590 }
591591
592592 v->valid = 1;
593 v->no_cachable = 0;
593 v->no_cacheable = 0;
594594 v->not_found = 0;
595595
596596 h = a->elts;
690690 if (n + prefix == var->len && n == header[i].key.len) {
691691 v->len = header[i].value.len;
692692 v->valid = 1;
693 v->no_cachable = 0;
693 v->no_cacheable = 0;
694694 v->not_found = 0;
695695 v->data = header[i].value.data;
696696
729729 }
730730
731731 v->valid = 1;
732 v->no_cachable = 0;
732 v->no_cacheable = 0;
733733 v->not_found = 0;
734734
735735 return NGX_OK;
748748
749749 v->len = sizeof(in_addr_t);
750750 v->valid = 1;
751 v->no_cachable = 0;
751 v->no_cacheable = 0;
752752 v->not_found = 0;
753753 v->data = (u_char *) &sin->sin_addr.s_addr;
754754
762762 {
763763 v->len = r->connection->addr_text.len;
764764 v->valid = 1;
765 v->no_cachable = 0;
765 v->no_cacheable = 0;
766766 v->not_found = 0;
767767 v->data = r->connection->addr_text.data;
768768
779779
780780 v->len = 0;
781781 v->valid = 1;
782 v->no_cachable = 0;
782 v->no_cacheable = 0;
783783 v->not_found = 0;
784784
785785 v->data = ngx_palloc(r->pool, sizeof("65535") - 1);
831831 v->len = ngx_inet_ntop(c->listening->family, &r->in_addr,
832832 v->data, INET_ADDRSTRLEN);
833833 v->valid = 1;
834 v->no_cachable = 0;
834 v->no_cacheable = 0;
835835 v->not_found = 0;
836836
837837 return NGX_OK;
844844 {
845845 v->len = r->port_text->len - 1;
846846 v->valid = 1;
847 v->no_cachable = 0;
847 v->no_cacheable = 0;
848848 v->not_found = 0;
849849 v->data = r->port_text->data + 1;
850850
861861 if (r->connection->ssl) {
862862 v->len = sizeof("https") - 1;
863863 v->valid = 1;
864 v->no_cachable = 0;
864 v->no_cacheable = 0;
865865 v->not_found = 0;
866866 v->data = (u_char *) "https";
867867
872872
873873 v->len = sizeof("http") - 1;
874874 v->valid = 1;
875 v->no_cachable = 0;
875 v->no_cacheable = 0;
876876 v->not_found = 0;
877877 v->data = (u_char *) "http";
878878
885885 ngx_http_variable_value_t *v, uintptr_t data)
886886 {
887887 v->valid = 1;
888 v->no_cachable = 0;
888 v->no_cacheable = 0;
889889 v->not_found = 0;
890890
891891 if (r->args.len == 0) {
913913 if (clcf->root_lengths == NULL) {
914914 v->len = clcf->root.len;
915915 v->valid = 1;
916 v->no_cachable = 0;
916 v->no_cacheable = 0;
917917 v->not_found = 0;
918918 v->data = clcf->root.data;
919919
933933
934934 v->len = path.len;
935935 v->valid = 1;
936 v->no_cachable = 0;
936 v->no_cacheable = 0;
937937 v->not_found = 0;
938938 v->data = path.data;
939939 }
957957
958958 v->len = path.len - 1;
959959 v->valid = 1;
960 v->no_cachable = 0;
960 v->no_cacheable = 0;
961961 v->not_found = 0;
962962 v->data = path.data;
963963
972972 if (r->main->method_name.data) {
973973 v->len = r->main->method_name.len;
974974 v->valid = 1;
975 v->no_cachable = 0;
975 v->no_cacheable = 0;
976976 v->not_found = 0;
977977 v->data = r->main->method_name.data;
978978
10031003
10041004 v->len = r->headers_in.user.len;
10051005 v->valid = 1;
1006 v->no_cachable = 0;
1006 v->no_cacheable = 0;
10071007 v->not_found = 0;
10081008 v->data = r->headers_in.user.data;
10091009
10311031
10321032 v->len = ngx_sprintf(p, "%O", sent) - p;
10331033 v->valid = 1;
1034 v->no_cachable = 0;
1034 v->no_cacheable = 0;
10351035 v->not_found = 0;
10361036 v->data = p;
10371037
10461046 if (r->headers_out.content_type.len) {
10471047 v->len = r->headers_out.content_type.len;
10481048 v->valid = 1;
1049 v->no_cachable = 0;
1049 v->no_cacheable = 0;
10501050 v->not_found = 0;
10511051 v->data = r->headers_out.content_type.data;
10521052
10671067 if (r->headers_out.content_length) {
10681068 v->len = r->headers_out.content_length->value.len;
10691069 v->valid = 1;
1070 v->no_cachable = 0;
1070 v->no_cacheable = 0;
10711071 v->not_found = 0;
10721072 v->data = r->headers_out.content_length->value.data;
10731073
10821082
10831083 v->len = ngx_sprintf(p, "%O", r->headers_out.content_length_n) - p;
10841084 v->valid = 1;
1085 v->no_cachable = 0;
1085 v->no_cacheable = 0;
10861086 v->not_found = 0;
10871087 v->data = p;
10881088
11041104 if (r->headers_out.last_modified) {
11051105 v->len = r->headers_out.last_modified->value.len;
11061106 v->valid = 1;
1107 v->no_cachable = 0;
1107 v->no_cacheable = 0;
11081108 v->not_found = 0;
11091109 v->data = r->headers_out.last_modified->value.data;
11101110
11201120
11211121 v->len = ngx_http_time(p, r->headers_out.last_modified_time) - p;
11221122 v->valid = 1;
1123 v->no_cachable = 0;
1123 v->no_cacheable = 0;
11241124 v->not_found = 0;
11251125 v->data = p;
11261126
11511151
11521152 v->len = len;
11531153 v->valid = 1;
1154 v->no_cachable = 0;
1154 v->no_cacheable = 0;
11551155 v->not_found = 0;
11561156 v->data = (u_char *) p;
11571157
11781178
11791179 v->len = ngx_sprintf(p, "timeout=%T", clcf->keepalive_header) - p;
11801180 v->valid = 1;
1181 v->no_cachable = 0;
1181 v->no_cacheable = 0;
11821182 v->not_found = 0;
11831183 v->data = p;
11841184
11991199 if (r->chunked) {
12001200 v->len = sizeof("chunked") - 1;
12011201 v->valid = 1;
1202 v->no_cachable = 0;
1202 v->no_cacheable = 0;
12031203 v->not_found = 0;
12041204 v->data = (u_char *) "chunked";
12051205
12181218 if (r->request_complete) {
12191219 v->len = 2;
12201220 v->valid = 1;
1221 v->no_cachable = 0;
1221 v->no_cacheable = 0;
12221222 v->not_found = 0;
12231223 v->data = (u_char *) "OK";
12241224
12271227
12281228 v->len = 0;
12291229 v->valid = 1;
1230 v->no_cachable = 0;
1230 v->no_cacheable = 0;
12311231 v->not_found = 0;
12321232 v->data = (u_char *) "";
12331233
12471247
12481248 v->len = r->request_body->temp_file->file.name.len;
12491249 v->valid = 1;
1250 v->no_cachable = 0;
1250 v->no_cacheable = 0;
12511251 v->not_found = 0;
12521252 v->data = r->request_body->temp_file->file.name.data;
12531253
12611261 {
12621262 v->len = sizeof(NGINX_VERSION) - 1;
12631263 v->valid = 1;
1264 v->no_cachable = 0;
1264 v->no_cacheable = 0;
12651265 v->not_found = 0;
12661266 v->data = (u_char *) NGINX_VERSION;
12671267
13691369 if (ngx_strncmp(v[i].name.data, "upstream_http_", 14) == 0) {
13701370 v[i].get_handler = ngx_http_upstream_header_variable;
13711371 v[i].data = (uintptr_t) &v[i].name;
1372 v[i].flags = NGX_HTTP_VAR_NOCACHABLE;
1372 v[i].flags = NGX_HTTP_VAR_NOCACHEABLE;
13731373
13741374 continue;
13751375 }
2525 ngx_http_variable_value_t *v, uintptr_t data);
2626
2727
28 #define NGX_HTTP_VAR_CHANGABLE 1
29 #define NGX_HTTP_VAR_NOCACHABLE 2
30 #define NGX_HTTP_VAR_INDEXED 4
31 #define NGX_HTTP_VAR_NOHASH 8
28 #define NGX_HTTP_VAR_CHANGEABLE 1
29 #define NGX_HTTP_VAR_NOCACHEABLE 2
30 #define NGX_HTTP_VAR_INDEXED 4
31 #define NGX_HTTP_VAR_NOHASH 8
3232
3333
3434 struct ngx_http_variable_s {
1313 ngx_int_t type);
1414 static void ngx_start_garbage_collector(ngx_cycle_t *cycle, ngx_int_t type);
1515 static void ngx_signal_worker_processes(ngx_cycle_t *cycle, int signo);
16 static ngx_uint_t ngx_reap_childs(ngx_cycle_t *cycle);
16 static ngx_uint_t ngx_reap_children(ngx_cycle_t *cycle);
1717 static void ngx_master_process_exit(ngx_cycle_t *cycle);
1818 static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data);
1919 static void ngx_worker_process_init(ngx_cycle_t *cycle, ngx_uint_t priority);
156156
157157 if (ngx_reap) {
158158 ngx_reap = 0;
159 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "reap childs");
160
161 live = ngx_reap_childs(cycle);
159 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "reap children");
160
161 live = ngx_reap_children(cycle);
162162 }
163163
164164 if (!live && (ngx_terminate || ngx_quit)) {
495495
496496
497497 static ngx_uint_t
498 ngx_reap_childs(ngx_cycle_t *cycle)
498 ngx_reap_children(ngx_cycle_t *cycle)
499499 {
500500 ngx_int_t i, n;
501501 ngx_uint_t live;