Mercurial > hg > nginx
annotate src/http/ngx_http_file_cache.c @ 3589:1c2e8b92751d stable-0.7
merge r3478:
reset a parsing state to parse correctly an upstream response,
if 400 or 414 response has been redirected to upstream
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 07 Jun 2010 11:45:04 +0000 |
parents | e1409e56ba7c |
children | 0d8b8c84bab7 |
rev | line source |
---|---|
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
265
diff
changeset
|
1 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
265
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
265
diff
changeset
|
4 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
265
diff
changeset
|
5 |
202
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
6 |
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 #include <ngx_config.h> |
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_core.h> |
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 #include <ngx_http.h> |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
10 #include <ngx_md5.h> |
202
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
12 |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
13 static ngx_int_t ngx_http_file_cache_exists(ngx_http_file_cache_t *cache, |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
14 ngx_http_cache_t *c); |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
15 static ngx_http_file_cache_node_t * |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
16 ngx_http_file_cache_lookup(ngx_http_file_cache_t *cache, u_char *key); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
17 static void ngx_http_file_cache_rbtree_insert_value(ngx_rbtree_node_t *temp, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
18 ngx_rbtree_node_t *node, ngx_rbtree_node_t *sentinel); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
19 static void ngx_http_file_cache_cleanup(void *data); |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
20 static time_t ngx_http_file_cache_forced_expire(ngx_http_file_cache_t *cache); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
21 static time_t ngx_http_file_cache_expire(ngx_http_file_cache_t *cache); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
22 static void ngx_http_file_cache_delete(ngx_http_file_cache_t *cache, |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
23 ngx_queue_t *q, u_char *name); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
24 static ngx_int_t |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
25 ngx_http_file_cache_manager_sleep(ngx_http_file_cache_t *cache); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
26 static ngx_int_t ngx_http_file_cache_noop(ngx_tree_ctx_t *ctx, |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
27 ngx_str_t *path); |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
28 static ngx_int_t ngx_http_file_cache_manage_file(ngx_tree_ctx_t *ctx, |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
29 ngx_str_t *path); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
30 static ngx_int_t ngx_http_file_cache_add_file(ngx_tree_ctx_t *ctx, |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
31 ngx_str_t *path); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
32 static ngx_int_t ngx_http_file_cache_add(ngx_http_file_cache_t *cache, |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
33 ngx_http_cache_t *c); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
34 static ngx_int_t ngx_http_file_cache_delete_file(ngx_tree_ctx_t *ctx, |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
35 ngx_str_t *path); |
202
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
36 |
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
37 |
3092 | 38 ngx_str_t ngx_http_cache_status[] = { |
39 ngx_string("MISS"), | |
40 ngx_string("EXPIRED"), | |
41 ngx_string("STALE"), | |
42 ngx_string("UPDATING"), | |
43 ngx_string("HIT") | |
44 }; | |
45 | |
46 | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
47 static u_char ngx_http_file_cache_key[] = { LF, 'K', 'E', 'Y', ':', ' ' }; |
202
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
48 |
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
49 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
50 static ngx_int_t |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
51 ngx_http_file_cache_init(ngx_shm_zone_t *shm_zone, void *data) |
202
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
52 { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
53 ngx_http_file_cache_t *ocache = data; |
202
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
54 |
2611
2bce3f6416c6
improve ngx_slab_alloc() error logging
Igor Sysoev <igor@sysoev.ru>
parents:
2606
diff
changeset
|
55 size_t len; |
3247
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
56 ngx_uint_t n; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
57 ngx_http_file_cache_t *cache; |
202
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
58 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
59 cache = shm_zone->data; |
202
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
60 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
61 if (ocache) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
62 if (ngx_strcmp(cache->path->name.data, ocache->path->name.data) != 0) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
63 ngx_log_error(NGX_LOG_EMERG, shm_zone->shm.log, 0, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
64 "cache \"%V\" uses the \"%V\" cache path " |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
65 "while previously it used the \"%V\" cache path", |
2716
d5896f6608e8
move zone name from ngx_shm_zone_t to ngx_shm_t to use Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2694
diff
changeset
|
66 &shm_zone->shm.name, &cache->path->name, |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
67 &ocache->path->name); |
202
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
68 |
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
69 return NGX_ERROR; |
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
70 } |
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
71 |
3247
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
72 for (n = 0; n < 3; n++) { |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
73 if (cache->path->level[n] != ocache->path->level[n]) { |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
74 ngx_log_error(NGX_LOG_EMERG, shm_zone->shm.log, 0, |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
75 "cache \"%V\" had previously different levels", |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
76 &shm_zone->shm.name); |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
77 return NGX_ERROR; |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
78 } |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
79 } |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
80 |
2720
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
81 cache->sh = ocache->sh; |
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
82 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
83 cache->shpool = ocache->shpool; |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
84 cache->bsize = ocache->bsize; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
85 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
86 cache->max_size /= cache->bsize; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
87 |
3247
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
88 if (!cache->sh->cold || cache->sh->loading) { |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
89 cache->path->loader = NULL; |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
90 } |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
91 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
92 return NGX_OK; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
93 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
94 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
95 cache->shpool = (ngx_slab_pool_t *) shm_zone->shm.addr; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
96 |
2720
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
97 if (shm_zone->shm.exists) { |
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
98 cache->sh = cache->shpool->data; |
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
99 cache->bsize = ngx_fs_bsize(cache->path->name.data); |
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
100 |
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
101 return NGX_OK; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
102 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
103 |
2720
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
104 cache->sh = ngx_slab_alloc(cache->shpool, sizeof(ngx_http_file_cache_sh_t)); |
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
105 if (cache->sh == NULL) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
106 return NGX_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
107 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
108 |
2720
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
109 cache->shpool->data = cache->sh; |
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
110 |
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
111 ngx_rbtree_init(&cache->sh->rbtree, &cache->sh->sentinel, |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
112 ngx_http_file_cache_rbtree_insert_value); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
113 |
2720
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
114 ngx_queue_init(&cache->sh->queue); |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
115 |
2720
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
116 cache->sh->cold = 1; |
3247
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
117 cache->sh->loading = 0; |
2720
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
118 cache->sh->size = 0; |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
119 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
120 cache->bsize = ngx_fs_bsize(cache->path->name.data); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
121 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
122 cache->max_size /= cache->bsize; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
123 |
2716
d5896f6608e8
move zone name from ngx_shm_zone_t to ngx_shm_t to use Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2694
diff
changeset
|
124 len = sizeof(" in cache keys zone \"\"") + shm_zone->shm.name.len; |
2611
2bce3f6416c6
improve ngx_slab_alloc() error logging
Igor Sysoev <igor@sysoev.ru>
parents:
2606
diff
changeset
|
125 |
2bce3f6416c6
improve ngx_slab_alloc() error logging
Igor Sysoev <igor@sysoev.ru>
parents:
2606
diff
changeset
|
126 cache->shpool->log_ctx = ngx_slab_alloc(cache->shpool, len); |
2bce3f6416c6
improve ngx_slab_alloc() error logging
Igor Sysoev <igor@sysoev.ru>
parents:
2606
diff
changeset
|
127 if (cache->shpool->log_ctx == NULL) { |
2bce3f6416c6
improve ngx_slab_alloc() error logging
Igor Sysoev <igor@sysoev.ru>
parents:
2606
diff
changeset
|
128 return NGX_ERROR; |
2bce3f6416c6
improve ngx_slab_alloc() error logging
Igor Sysoev <igor@sysoev.ru>
parents:
2606
diff
changeset
|
129 } |
2bce3f6416c6
improve ngx_slab_alloc() error logging
Igor Sysoev <igor@sysoev.ru>
parents:
2606
diff
changeset
|
130 |
2bce3f6416c6
improve ngx_slab_alloc() error logging
Igor Sysoev <igor@sysoev.ru>
parents:
2606
diff
changeset
|
131 ngx_sprintf(cache->shpool->log_ctx, " in cache keys zone \"%V\"%Z", |
2716
d5896f6608e8
move zone name from ngx_shm_zone_t to ngx_shm_t to use Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2694
diff
changeset
|
132 &shm_zone->shm.name); |
2611
2bce3f6416c6
improve ngx_slab_alloc() error logging
Igor Sysoev <igor@sysoev.ru>
parents:
2606
diff
changeset
|
133 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
134 return NGX_OK; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
135 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
136 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
137 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
138 void |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
139 ngx_http_file_cache_create_key(ngx_http_request_t *r) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
140 { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
141 size_t len; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
142 ngx_str_t *key; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
143 ngx_uint_t i; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
144 ngx_md5_t md5; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
145 ngx_http_cache_t *c; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
146 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
147 c = r->cache; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
148 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
149 len = 0; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
150 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
151 ngx_crc32_init(c->crc32); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
152 ngx_md5_init(&md5); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
153 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
154 key = c->keys.elts; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
155 for (i = 0; i < c->keys.nelts; i++) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
156 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
157 "http cache key: \"%V\"", &key[i]); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
158 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
159 len += key[i].len; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
160 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
161 ngx_crc32_update(&c->crc32, key[i].data, key[i].len); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
162 ngx_md5_update(&md5, key[i].data, key[i].len); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
163 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
164 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
165 c->header_start = sizeof(ngx_http_file_cache_header_t) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
166 + sizeof(ngx_http_file_cache_key) + len + 1; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
167 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
168 ngx_crc32_final(c->crc32); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
169 ngx_md5_final(c->key, &md5); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
170 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
171 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
172 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
173 ngx_int_t |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
174 ngx_http_file_cache_open(ngx_http_request_t *r) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
175 { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
176 u_char *p; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
177 time_t now; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
178 ssize_t n; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
179 ngx_int_t rc, rv; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
180 ngx_uint_t cold, test; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
181 ngx_path_t *path; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
182 ngx_http_cache_t *c; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
183 ngx_pool_cleanup_t *cln; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
184 ngx_open_file_info_t of; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
185 ngx_http_file_cache_t *cache; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
186 ngx_http_core_loc_conf_t *clcf; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
187 ngx_http_file_cache_header_t *h; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
188 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
189 c = r->cache; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
190 cache = c->file_cache; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
191 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
192 cln = ngx_pool_cleanup_add(r->pool, 0); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
193 if (cln == NULL) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
194 return NGX_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
195 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
196 |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
197 rc = ngx_http_file_cache_exists(cache, c); |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
198 |
2944
f892042956e3
merge r2895, r2896, r2926, r2927, r2928, r2930, and r2936:
Igor Sysoev <igor@sysoev.ru>
parents:
2720
diff
changeset
|
199 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
f892042956e3
merge r2895, r2896, r2926, r2927, r2928, r2930, and r2936:
Igor Sysoev <igor@sysoev.ru>
parents:
2720
diff
changeset
|
200 "http file cache exists: %i e:%d", rc, c->exists); |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
201 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
202 if (rc == NGX_ERROR) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
203 return rc; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
204 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
205 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
206 cln->handler = ngx_http_file_cache_cleanup; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
207 cln->data = c; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
208 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
209 if (rc == NGX_AGAIN) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
210 return rc; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
211 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
212 |
2720
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
213 cold = cache->sh->cold; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
214 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
215 if (rc == NGX_OK) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
216 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
217 if (c->error) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
218 return c->error; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
219 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
220 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
221 c->temp_file = 1; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
222 test = c->exists ? 1 : 0; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
223 rv = NGX_DECLINED; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
224 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
225 } else { /* rc == NGX_DECLINED */ |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
226 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
227 if (c->min_uses > 1) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
228 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
229 if (!cold) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
230 return NGX_AGAIN; |
202
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
231 } |
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
232 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
233 test = 1; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
234 rv = NGX_AGAIN; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
235 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
236 } else { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
237 c->temp_file = 1; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
238 test = cold ? 1 : 0; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
239 rv = NGX_DECLINED; |
202
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
240 } |
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
241 } |
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
242 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
243 path = cache->path; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
244 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
245 c->file.name.len = path->name.len + 1 + path->len |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
246 + 2 * NGX_HTTP_CACHE_KEY_LEN; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
247 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
248 c->file.name.data = ngx_pnalloc(r->pool, c->file.name.len + 1); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
249 if (c->file.name.data == NULL) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
250 return NGX_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
251 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
252 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
253 ngx_memcpy(c->file.name.data, path->name.data, path->name.len); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
254 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
255 p = c->file.name.data + path->name.len + 1 + path->len; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
256 p = ngx_hex_dump(p, c->key, NGX_HTTP_CACHE_KEY_LEN); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
257 *p = '\0'; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
258 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
259 ngx_create_hashed_filename(path, c->file.name.data, c->file.name.len); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
260 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
261 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
262 "cache file: \"%s\"", c->file.name.data); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
263 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
264 if (!test) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
265 return NGX_DECLINED; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
266 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
267 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
268 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
269 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
270 ngx_memzero(&of, sizeof(ngx_open_file_info_t)); |
202
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
271 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
272 of.uniq = c->uniq; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
273 of.valid = clcf->open_file_cache_valid; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
274 of.min_uses = clcf->open_file_cache_min_uses; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
275 of.events = clcf->open_file_cache_events; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
276 of.directio = NGX_OPEN_FILE_DIRECTIO_OFF; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
277 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
278 if (ngx_open_cached_file(clcf->open_file_cache, &c->file.name, &of, r->pool) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
279 != NGX_OK) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
280 { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
281 switch (of.err) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
282 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
283 case 0: |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
284 return NGX_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
285 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
286 case NGX_ENOENT: |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
287 case NGX_ENOTDIR: |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
288 return rv; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
289 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
290 default: |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
291 ngx_log_error(NGX_LOG_CRIT, r->connection->log, of.err, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
292 ngx_open_file_n " \"%s\" failed", c->file.name.data); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
293 return NGX_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
294 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
295 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
296 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
297 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
298 "http file cache fd: %d", of.fd); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
299 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
300 c->file.fd = of.fd; |
2603
f9bd7999eb08
fix segfault if ngx_read_file() will fail
Igor Sysoev <igor@sysoev.ru>
parents:
2600
diff
changeset
|
301 c->file.log = r->connection->log; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
302 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
303 c->buf = ngx_create_temp_buf(r->pool, c->body_start); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
304 if (c->buf == NULL) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
305 return NGX_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
306 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
307 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
308 n = ngx_read_file(&c->file, c->buf->pos, c->body_start, 0); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
309 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
310 if (n == NGX_ERROR) { |
202
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
311 return n; |
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
312 } |
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
313 |
3439
3354dfba9da4
merge r3137, r3198, r3199, r3353, r3370, r3371, r3398, r3399:
Igor Sysoev <igor@sysoev.ru>
parents:
3248
diff
changeset
|
314 if ((size_t) n < c->header_start) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
315 ngx_log_error(NGX_LOG_CRIT, r->connection->log, 0, |
477 | 316 "cache file \"%s\" is too small", c->file.name.data); |
202
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
317 return NGX_ERROR; |
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
318 } |
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
319 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
320 h = (ngx_http_file_cache_header_t *) c->buf->pos; |
202
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
321 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
322 if (h->crc32 != c->crc32 || (size_t) h->header_start != c->header_start) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
323 ngx_log_error(NGX_LOG_CRIT, r->connection->log, 0, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
324 "cache file \"%s\" has md5 collision", c->file.name.data); |
202
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
325 return NGX_DECLINED; |
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
326 } |
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
327 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
328 c->buf->last += n; |
477 | 329 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
330 c->valid_sec = h->valid_sec; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
331 c->last_modified = h->last_modified; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
332 c->date = h->date; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
333 c->valid_msec = h->valid_msec; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
334 c->length = of.size; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
335 c->body_start = h->body_start; |
477 | 336 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
337 r->cached = 1; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
338 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
339 if (cold) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
340 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
341 ngx_shmtx_lock(&cache->shpool->mutex); |
477 | 342 |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
343 if (!c->node->exists) { |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
344 c->node->uses = 1; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
345 c->node->body_start = c->body_start; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
346 c->node->exists = 1; |
2944
f892042956e3
merge r2895, r2896, r2926, r2927, r2928, r2930, and r2936:
Igor Sysoev <igor@sysoev.ru>
parents:
2720
diff
changeset
|
347 c->node->uniq = of.uniq; |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
348 |
2720
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
349 cache->sh->size += (c->length + cache->bsize - 1) / cache->bsize; |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
350 } |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
351 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
352 ngx_shmtx_unlock(&cache->shpool->mutex); |
202
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
353 } |
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
354 |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
355 now = ngx_time(); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
356 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
357 if (c->valid_sec < now) { |
202
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
358 |
2944
f892042956e3
merge r2895, r2896, r2926, r2927, r2928, r2930, and r2936:
Igor Sysoev <igor@sysoev.ru>
parents:
2720
diff
changeset
|
359 ngx_shmtx_lock(&cache->shpool->mutex); |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
202
diff
changeset
|
360 |
2944
f892042956e3
merge r2895, r2896, r2926, r2927, r2928, r2930, and r2936:
Igor Sysoev <igor@sysoev.ru>
parents:
2720
diff
changeset
|
361 if (c->node->updating) { |
f892042956e3
merge r2895, r2896, r2926, r2927, r2928, r2930, and r2936:
Igor Sysoev <igor@sysoev.ru>
parents:
2720
diff
changeset
|
362 rc = NGX_HTTP_CACHE_UPDATING; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
363 |
2944
f892042956e3
merge r2895, r2896, r2926, r2927, r2928, r2930, and r2936:
Igor Sysoev <igor@sysoev.ru>
parents:
2720
diff
changeset
|
364 } else { |
f892042956e3
merge r2895, r2896, r2926, r2927, r2928, r2930, and r2936:
Igor Sysoev <igor@sysoev.ru>
parents:
2720
diff
changeset
|
365 c->node->updating = 1; |
f892042956e3
merge r2895, r2896, r2926, r2927, r2928, r2930, and r2936:
Igor Sysoev <igor@sysoev.ru>
parents:
2720
diff
changeset
|
366 rc = NGX_HTTP_CACHE_STALE; |
f892042956e3
merge r2895, r2896, r2926, r2927, r2928, r2930, and r2936:
Igor Sysoev <igor@sysoev.ru>
parents:
2720
diff
changeset
|
367 } |
f892042956e3
merge r2895, r2896, r2926, r2927, r2928, r2930, and r2936:
Igor Sysoev <igor@sysoev.ru>
parents:
2720
diff
changeset
|
368 |
f892042956e3
merge r2895, r2896, r2926, r2927, r2928, r2930, and r2936:
Igor Sysoev <igor@sysoev.ru>
parents:
2720
diff
changeset
|
369 ngx_shmtx_unlock(&cache->shpool->mutex); |
f892042956e3
merge r2895, r2896, r2926, r2927, r2928, r2930, and r2936:
Igor Sysoev <igor@sysoev.ru>
parents:
2720
diff
changeset
|
370 |
f892042956e3
merge r2895, r2896, r2926, r2927, r2928, r2930, and r2936:
Igor Sysoev <igor@sysoev.ru>
parents:
2720
diff
changeset
|
371 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
f892042956e3
merge r2895, r2896, r2926, r2927, r2928, r2930, and r2936:
Igor Sysoev <igor@sysoev.ru>
parents:
2720
diff
changeset
|
372 "http file cache expired: %i %T %T", |
f892042956e3
merge r2895, r2896, r2926, r2927, r2928, r2930, and r2936:
Igor Sysoev <igor@sysoev.ru>
parents:
2720
diff
changeset
|
373 rc, c->valid_sec, now); |
f892042956e3
merge r2895, r2896, r2926, r2927, r2928, r2930, and r2936:
Igor Sysoev <igor@sysoev.ru>
parents:
2720
diff
changeset
|
374 |
f892042956e3
merge r2895, r2896, r2926, r2927, r2928, r2930, and r2936:
Igor Sysoev <igor@sysoev.ru>
parents:
2720
diff
changeset
|
375 return rc; |
202
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
376 } |
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
377 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
378 return NGX_OK; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
379 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
380 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
381 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
382 static ngx_int_t |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
383 ngx_http_file_cache_exists(ngx_http_file_cache_t *cache, ngx_http_cache_t *c) |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
384 { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
385 ngx_int_t rc; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
386 ngx_http_file_cache_node_t *fcn; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
387 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
388 ngx_shmtx_lock(&cache->shpool->mutex); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
389 |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
390 fcn = ngx_http_file_cache_lookup(cache, c->key); |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
391 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
392 if (fcn) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
393 ngx_queue_remove(&fcn->queue); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
394 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
395 if (fcn->error) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
396 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
397 if (fcn->valid_sec < ngx_time()) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
398 goto renew; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
399 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
400 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
401 rc = NGX_OK; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
402 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
403 goto done; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
404 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
405 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
406 fcn->uses++; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
407 fcn->count++; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
408 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
409 if (fcn->exists) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
410 |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
411 c->exists = fcn->exists; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
412 c->body_start = fcn->body_start; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
413 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
414 rc = NGX_OK; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
415 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
416 goto done; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
417 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
418 |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
419 if (fcn->uses >= c->min_uses) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
420 |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
421 c->exists = fcn->exists; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
422 c->body_start = fcn->body_start; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
423 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
424 rc = NGX_OK; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
425 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
426 } else { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
427 rc = NGX_AGAIN; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
428 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
429 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
430 goto done; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
431 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
432 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
433 fcn = ngx_slab_alloc_locked(cache->shpool, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
434 sizeof(ngx_http_file_cache_node_t)); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
435 if (fcn == NULL) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
436 ngx_shmtx_unlock(&cache->shpool->mutex); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
437 |
2693 | 438 (void) ngx_http_file_cache_forced_expire(cache); |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
439 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
440 ngx_shmtx_lock(&cache->shpool->mutex); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
441 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
442 fcn = ngx_slab_alloc_locked(cache->shpool, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
443 sizeof(ngx_http_file_cache_node_t)); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
444 if (fcn == NULL) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
445 rc = NGX_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
446 goto failed; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
447 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
448 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
449 |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
450 ngx_memcpy((u_char *) &fcn->node.key, c->key, sizeof(ngx_rbtree_key_t)); |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
451 |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
452 ngx_memcpy(fcn->key, &c->key[sizeof(ngx_rbtree_key_t)], |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
453 NGX_HTTP_CACHE_KEY_LEN - sizeof(ngx_rbtree_key_t)); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
454 |
2720
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
455 ngx_rbtree_insert(&cache->sh->rbtree, &fcn->node); |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
456 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
457 renew: |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
458 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
459 rc = NGX_DECLINED; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
460 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
461 fcn->uses = 1; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
462 fcn->count = 1; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
463 fcn->valid_msec = 0; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
464 fcn->error = 0; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
465 fcn->exists = 0; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
466 fcn->valid_sec = 0; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
467 fcn->uniq = 0; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
468 fcn->body_start = 0; |
2632 | 469 fcn->length = 0; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
470 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
471 done: |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
472 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
473 fcn->expire = ngx_time() + cache->inactive; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
474 |
2720
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
475 ngx_queue_insert_head(&cache->sh->queue, &fcn->queue); |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
476 |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
477 c->uniq = fcn->uniq; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
478 c->error = fcn->error; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
479 c->node = fcn; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
480 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
481 failed: |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
482 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
483 ngx_shmtx_unlock(&cache->shpool->mutex); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
484 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
485 return rc; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
486 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
487 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
488 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
489 static ngx_http_file_cache_node_t * |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
490 ngx_http_file_cache_lookup(ngx_http_file_cache_t *cache, u_char *key) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
491 { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
492 ngx_int_t rc; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
493 ngx_rbtree_key_t node_key; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
494 ngx_rbtree_node_t *node, *sentinel; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
495 ngx_http_file_cache_node_t *fcn; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
496 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
497 ngx_memcpy((u_char *) &node_key, key, sizeof(ngx_rbtree_key_t)); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
498 |
2720
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
499 node = cache->sh->rbtree.root; |
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
500 sentinel = cache->sh->rbtree.sentinel; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
501 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
502 while (node != sentinel) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
503 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
504 if (node_key < node->key) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
505 node = node->left; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
506 continue; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
507 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
508 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
509 if (node_key > node->key) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
510 node = node->right; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
511 continue; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
512 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
513 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
514 /* node_key == node->key */ |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
515 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
516 do { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
517 fcn = (ngx_http_file_cache_node_t *) node; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
518 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
519 rc = ngx_memcmp(&key[sizeof(ngx_rbtree_key_t)], fcn->key, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
520 NGX_HTTP_CACHE_KEY_LEN - sizeof(ngx_rbtree_key_t)); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
521 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
522 if (rc == 0) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
523 return fcn; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
524 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
525 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
526 node = (rc < 0) ? node->left : node->right; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
527 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
528 } while (node != sentinel && node_key == node->key); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
529 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
530 break; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
531 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
532 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
533 /* not found */ |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
534 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
535 return NULL; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
536 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
537 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
538 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
539 static void |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
540 ngx_http_file_cache_rbtree_insert_value(ngx_rbtree_node_t *temp, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
541 ngx_rbtree_node_t *node, ngx_rbtree_node_t *sentinel) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
542 { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
543 ngx_rbtree_node_t **p; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
544 ngx_http_file_cache_node_t *cn, *cnt; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
545 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
546 for ( ;; ) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
547 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
548 if (node->key < temp->key) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
549 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
550 p = &temp->left; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
551 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
552 } else if (node->key > temp->key) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
553 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
554 p = &temp->right; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
555 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
556 } else { /* node->key == temp->key */ |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
557 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
558 cn = (ngx_http_file_cache_node_t *) node; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
559 cnt = (ngx_http_file_cache_node_t *) temp; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
560 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
561 p = (ngx_memcmp(cn->key, cnt->key, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
562 NGX_HTTP_CACHE_KEY_LEN - sizeof(ngx_rbtree_key_t)) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
563 < 0) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
564 ? &temp->left : &temp->right; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
565 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
566 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
567 if (*p == sentinel) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
568 break; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
569 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
570 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
571 temp = *p; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
572 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
573 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
574 *p = node; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
575 node->parent = temp; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
576 node->left = sentinel; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
577 node->right = sentinel; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
578 ngx_rbt_red(node); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
579 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
580 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
581 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
582 void |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
583 ngx_http_file_cache_set_header(ngx_http_request_t *r, u_char *buf) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
584 { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
585 ngx_http_file_cache_header_t *h = (ngx_http_file_cache_header_t *) buf; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
586 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
587 u_char *p; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
588 ngx_str_t *key; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
589 ngx_uint_t i; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
590 ngx_http_cache_t *c; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
591 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
592 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
593 "http file cache set header"); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
594 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
595 c = r->cache; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
596 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
597 h->valid_sec = c->valid_sec; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
598 h->last_modified = c->last_modified; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
599 h->date = c->date; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
600 h->crc32 = c->crc32; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
601 h->valid_msec = (u_short) c->valid_msec; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
602 h->header_start = (u_short) c->header_start; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
603 h->body_start = (u_short) c->body_start; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
604 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
605 p = buf + sizeof(ngx_http_file_cache_header_t); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
606 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
607 p = ngx_cpymem(p, ngx_http_file_cache_key, sizeof(ngx_http_file_cache_key)); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
608 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
609 key = c->keys.elts; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
610 for (i = 0; i < c->keys.nelts; i++) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
611 p = ngx_copy(p, key[i].data, key[i].len); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
612 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
613 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
614 *p = LF; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
615 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
616 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
617 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
618 void |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
619 ngx_http_file_cache_update(ngx_http_request_t *r, ngx_temp_file_t *tf) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
620 { |
3247
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
621 off_t size, length; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
622 ngx_int_t rc; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
623 ngx_file_uniq_t uniq; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
624 ngx_file_info_t fi; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
625 ngx_http_cache_t *c; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
626 ngx_ext_rename_file_t ext; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
627 ngx_http_file_cache_t *cache; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
628 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
629 c = r->cache; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
630 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
631 if (c->updated) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
632 return; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
633 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
634 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
635 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
636 "http file cache update"); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
637 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
638 c->updated = 1; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
639 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
640 cache = c->file_cache; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
641 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
642 uniq = 0; |
3247
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
643 length = 0; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
644 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
645 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
646 "http file cache rename: \"%s\" to \"%s\"", |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
647 tf->file.name.data, c->file.name.data); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
648 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
649 ext.access = NGX_FILE_OWNER_ACCESS; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
650 ext.path_access = NGX_FILE_OWNER_ACCESS; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
651 ext.time = -1; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
652 ext.create_path = 1; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
653 ext.delete_file = 1; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
654 ext.log = r->connection->log; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
655 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
656 rc = ngx_ext_rename_file(&tf->file.name, &c->file.name, &ext); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
657 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
658 if (rc == NGX_OK) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
659 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
660 if (ngx_fd_info(tf->file.fd, &fi) == NGX_FILE_ERROR) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
661 ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
662 ngx_fd_info_n " \"%s\" failed", tf->file.name.data); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
663 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
664 rc = NGX_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
665 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
666 } else { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
667 uniq = ngx_file_uniq(&fi); |
3247
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
668 length = ngx_file_size(&fi); |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
669 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
670 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
671 |
3247
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
672 size = (length + cache->bsize - 1) / cache->bsize; |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
673 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
674 ngx_shmtx_lock(&cache->shpool->mutex); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
675 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
676 c->node->count--; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
677 c->node->uniq = uniq; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
678 c->node->body_start = c->body_start; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
679 |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
680 size = size - (c->node->length + cache->bsize - 1) / cache->bsize; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
681 |
3247
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
682 c->node->length = length; |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
683 |
2720
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
684 cache->sh->size += size; |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
685 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
686 if (rc == NGX_OK) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
687 c->node->exists = 1; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
688 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
689 |
2944
f892042956e3
merge r2895, r2896, r2926, r2927, r2928, r2930, and r2936:
Igor Sysoev <igor@sysoev.ru>
parents:
2720
diff
changeset
|
690 c->node->updating = 0; |
f892042956e3
merge r2895, r2896, r2926, r2927, r2928, r2930, and r2936:
Igor Sysoev <igor@sysoev.ru>
parents:
2720
diff
changeset
|
691 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
692 ngx_shmtx_unlock(&cache->shpool->mutex); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
693 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
694 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
695 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
696 ngx_int_t |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
697 ngx_http_cache_send(ngx_http_request_t *r) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
698 { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
699 ngx_int_t rc; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
700 ngx_buf_t *b; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
701 ngx_chain_t out; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
702 ngx_http_cache_t *c; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
703 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
704 c = r->cache; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
705 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
706 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
707 "http file cache send: %s", c->file.name.data); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
708 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
709 /* we need to allocate all before the header would be sent */ |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
710 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
711 b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t)); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
712 if (b == NULL) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
713 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
714 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
715 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
716 b->file = ngx_pcalloc(r->pool, sizeof(ngx_file_t)); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
717 if (b->file == NULL) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
718 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
719 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
720 |
3439
3354dfba9da4
merge r3137, r3198, r3199, r3353, r3370, r3371, r3398, r3399:
Igor Sysoev <igor@sysoev.ru>
parents:
3248
diff
changeset
|
721 r->header_only = (c->length - c->body_start) == 0; |
3354dfba9da4
merge r3137, r3198, r3199, r3353, r3370, r3371, r3398, r3399:
Igor Sysoev <igor@sysoev.ru>
parents:
3248
diff
changeset
|
722 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
723 rc = ngx_http_send_header(r); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
724 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
725 if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
726 return rc; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
727 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
728 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
729 b->file_pos = c->body_start; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
730 b->file_last = c->length; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
731 |
3439
3354dfba9da4
merge r3137, r3198, r3199, r3353, r3370, r3371, r3398, r3399:
Igor Sysoev <igor@sysoev.ru>
parents:
3248
diff
changeset
|
732 b->in_file = 1; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
733 b->last_buf = (r == r->main) ? 1: 0; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
734 b->last_in_chain = 1; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
735 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
736 b->file->fd = c->file.fd; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
737 b->file->name = c->file.name; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
738 b->file->log = r->connection->log; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
739 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
740 out.buf = b; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
741 out.next = NULL; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
742 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
743 return ngx_http_output_filter(r, &out); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
744 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
745 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
746 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
747 void |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
748 ngx_http_file_cache_free(ngx_http_request_t *r, ngx_temp_file_t *tf) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
749 { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
750 ngx_http_cache_t *c; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
751 ngx_http_file_cache_t *cache; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
752 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
753 c = r->cache; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
754 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
755 if (c->updated) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
756 return; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
757 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
758 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
759 c->updated = 1; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
760 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
761 cache = c->file_cache; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
762 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
763 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
764 "http file cache free"); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
765 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
766 ngx_shmtx_lock(&cache->shpool->mutex); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
767 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
768 c->node->count--; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
769 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
770 if (c->error) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
771 c->node->valid_sec = c->valid_sec; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
772 c->node->valid_msec = c->valid_msec; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
773 c->node->error = c->error; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
774 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
775 |
2944
f892042956e3
merge r2895, r2896, r2926, r2927, r2928, r2930, and r2936:
Igor Sysoev <igor@sysoev.ru>
parents:
2720
diff
changeset
|
776 c->node->updating = 0; |
f892042956e3
merge r2895, r2896, r2926, r2927, r2928, r2930, and r2936:
Igor Sysoev <igor@sysoev.ru>
parents:
2720
diff
changeset
|
777 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
778 ngx_shmtx_unlock(&cache->shpool->mutex); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
779 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
780 if (c->temp_file) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
781 if (tf && tf->file.fd != NGX_INVALID_FILE) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
782 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
783 "http file cache incomplete: \"%s\"", |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
784 tf->file.name.data); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
785 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
786 if (ngx_delete_file(tf->file.name.data) == NGX_FILE_ERROR) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
787 ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
788 ngx_delete_file_n " \"%s\" failed", |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
789 tf->file.name.data); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
790 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
791 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
792 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
793 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
794 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
795 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
796 static void |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
797 ngx_http_file_cache_cleanup(void *data) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
798 { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
799 ngx_http_cache_t *c = data; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
800 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
801 ngx_http_file_cache_t *cache; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
802 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
803 if (c->updated) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
804 return; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
805 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
806 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
807 c->updated = 1; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
808 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
809 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->file.log, 0, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
810 "http file cache cleanup"); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
811 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
812 if (c->error) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
813 return; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
814 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
815 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
816 cache = c->file_cache; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
817 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
818 ngx_shmtx_lock(&cache->shpool->mutex); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
819 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
820 c->node->count--; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
821 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
822 ngx_shmtx_unlock(&cache->shpool->mutex); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
823 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
824 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
825 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
826 static time_t |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
827 ngx_http_file_cache_forced_expire(ngx_http_file_cache_t *cache) |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
828 { |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
829 u_char *name; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
830 size_t len; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
831 time_t wait; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
832 ngx_uint_t tries; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
833 ngx_path_t *path; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
834 ngx_queue_t *q; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
835 ngx_http_file_cache_node_t *fcn; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
836 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
837 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0, |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
838 "http file cache forced expire"); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
839 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
840 path = cache->path; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
841 len = path->name.len + 1 + path->len + 2 * NGX_HTTP_CACHE_KEY_LEN; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
842 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
843 name = ngx_alloc(len + 1, ngx_cycle->log); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
844 if (name == NULL) { |
2694
49a1382b249b
set cache manager maximum sleep time to 10s
Igor Sysoev <igor@sysoev.ru>
parents:
2693
diff
changeset
|
845 return 10; |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
846 } |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
847 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
848 ngx_memcpy(name, path->name.data, path->name.len); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
849 |
2694
49a1382b249b
set cache manager maximum sleep time to 10s
Igor Sysoev <igor@sysoev.ru>
parents:
2693
diff
changeset
|
850 wait = 10; |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
851 tries = 0; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
852 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
853 ngx_shmtx_lock(&cache->shpool->mutex); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
854 |
2720
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
855 for (q = ngx_queue_last(&cache->sh->queue); |
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
856 q != ngx_queue_sentinel(&cache->sh->queue); |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
857 q = ngx_queue_prev(q)) |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
858 { |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
859 fcn = ngx_queue_data(q, ngx_http_file_cache_node_t, queue); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
860 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
861 ngx_log_debug6(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0, |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
862 "http file cache forced expire: #%d %d %02xd%02xd%02xd%02xd", |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
863 fcn->count, fcn->exists, |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
864 fcn->key[0], fcn->key[1], fcn->key[2], fcn->key[3]); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
865 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
866 if (fcn->count) { |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
867 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
868 if (tries++ < 20) { |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
869 continue; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
870 } |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
871 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
872 wait = 1; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
873 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
874 break; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
875 } |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
876 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
877 if (!fcn->exists) { |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
878 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
879 ngx_queue_remove(q); |
2720
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
880 ngx_rbtree_delete(&cache->sh->rbtree, &fcn->node); |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
881 ngx_slab_free_locked(cache->shpool, fcn); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
882 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
883 break; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
884 } |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
885 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
886 ngx_http_file_cache_delete(cache, q, name); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
887 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
888 break; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
889 } |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
890 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
891 ngx_shmtx_unlock(&cache->shpool->mutex); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
892 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
893 ngx_free(name); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
894 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
895 return wait; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
896 } |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
897 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
898 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
899 static time_t |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
900 ngx_http_file_cache_expire(ngx_http_file_cache_t *cache) |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
901 { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
902 u_char *name, *p; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
903 size_t len; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
904 time_t now, wait; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
905 ngx_path_t *path; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
906 ngx_queue_t *q; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
907 ngx_http_file_cache_node_t *fcn; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
908 u_char key[2 * NGX_HTTP_CACHE_KEY_LEN]; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
909 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
910 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
911 "http file cache expire"); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
912 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
913 path = cache->path; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
914 len = path->name.len + 1 + path->len + 2 * NGX_HTTP_CACHE_KEY_LEN; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
915 |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
916 name = ngx_alloc(len + 1, ngx_cycle->log); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
917 if (name == NULL) { |
2694
49a1382b249b
set cache manager maximum sleep time to 10s
Igor Sysoev <igor@sysoev.ru>
parents:
2693
diff
changeset
|
918 return 10; |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
919 } |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
920 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
921 ngx_memcpy(name, path->name.data, path->name.len); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
922 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
923 now = ngx_time(); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
924 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
925 ngx_shmtx_lock(&cache->shpool->mutex); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
926 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
927 for ( ;; ) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
928 |
2720
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
929 if (ngx_queue_empty(&cache->sh->queue)) { |
2694
49a1382b249b
set cache manager maximum sleep time to 10s
Igor Sysoev <igor@sysoev.ru>
parents:
2693
diff
changeset
|
930 wait = 10; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
931 break; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
932 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
933 |
2720
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
934 q = ngx_queue_last(&cache->sh->queue); |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
935 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
936 fcn = ngx_queue_data(q, ngx_http_file_cache_node_t, queue); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
937 |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
938 wait = fcn->expire - now; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
939 |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
940 if (wait > 0) { |
2694
49a1382b249b
set cache manager maximum sleep time to 10s
Igor Sysoev <igor@sysoev.ru>
parents:
2693
diff
changeset
|
941 wait = wait > 10 ? 10 : wait; |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
942 break; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
943 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
944 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
945 ngx_log_debug6(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
946 "http file cache expire: #%d %d %02xd%02xd%02xd%02xd", |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
947 fcn->count, fcn->exists, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
948 fcn->key[0], fcn->key[1], fcn->key[2], fcn->key[3]); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
949 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
950 if (fcn->count) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
951 |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
952 p = ngx_hex_dump(key, (u_char *) &fcn->node.key, |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
953 sizeof(ngx_rbtree_key_t)); |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
954 |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
955 len = NGX_HTTP_CACHE_KEY_LEN - sizeof(ngx_rbtree_key_t); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
956 (void) ngx_hex_dump(p, fcn->key, len); |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
957 |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
958 /* |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
959 * abnormally exited workers may leave locked cache entries, |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
960 * and although it may be safe to remove them completely, |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
961 * we prefer to remove them from inactive queue and rbtree |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
962 * only, and to allow other leaks |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
963 */ |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
964 |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
965 ngx_queue_remove(q); |
2720
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
966 ngx_rbtree_delete(&cache->sh->rbtree, &fcn->node); |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
967 |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
968 ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, |
2604
2a35ed59827d
fix logged long locked cache entry name and add count
Igor Sysoev <igor@sysoev.ru>
parents:
2603
diff
changeset
|
969 "ignore long locked inactive cache entry %*s, count:%d", |
2a35ed59827d
fix logged long locked cache entry name and add count
Igor Sysoev <igor@sysoev.ru>
parents:
2603
diff
changeset
|
970 2 * NGX_HTTP_CACHE_KEY_LEN, key, fcn->count); |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
971 |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
972 continue; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
973 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
974 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
975 if (!fcn->exists) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
976 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
977 ngx_queue_remove(q); |
2720
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
978 ngx_rbtree_delete(&cache->sh->rbtree, &fcn->node); |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
979 ngx_slab_free_locked(cache->shpool, fcn); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
980 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
981 continue; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
982 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
983 |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
984 ngx_http_file_cache_delete(cache, q, name); |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
985 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
986 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
987 ngx_shmtx_unlock(&cache->shpool->mutex); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
988 |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
989 ngx_free(name); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
990 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
991 return wait; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
992 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
993 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
994 |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
995 static void |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
996 ngx_http_file_cache_delete(ngx_http_file_cache_t *cache, ngx_queue_t *q, |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
997 u_char *name) |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
998 { |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
999 u_char *p; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1000 size_t len; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1001 ngx_path_t *path; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1002 ngx_http_file_cache_node_t *fcn; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1003 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1004 fcn = ngx_queue_data(q, ngx_http_file_cache_node_t, queue); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1005 |
2720
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
1006 cache->sh->size -= (fcn->length + cache->bsize - 1) / cache->bsize; |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1007 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1008 path = cache->path; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1009 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1010 p = name + path->name.len + 1 + path->len; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1011 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1012 p = ngx_hex_dump(p, (u_char *) &fcn->node.key, sizeof(ngx_rbtree_key_t)); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1013 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1014 len = NGX_HTTP_CACHE_KEY_LEN - sizeof(ngx_rbtree_key_t); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1015 p = ngx_hex_dump(p, fcn->key, len); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1016 *p = '\0'; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1017 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1018 ngx_queue_remove(q); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1019 |
2720
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
1020 ngx_rbtree_delete(&cache->sh->rbtree, &fcn->node); |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1021 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1022 ngx_slab_free_locked(cache->shpool, fcn); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1023 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1024 ngx_shmtx_unlock(&cache->shpool->mutex); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1025 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1026 len = path->name.len + 1 + path->len + 2 * NGX_HTTP_CACHE_KEY_LEN; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1027 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1028 ngx_create_hashed_filename(path, name, len); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1029 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1030 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0, |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1031 "http file cache expire: \"%s\"", name); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1032 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1033 if (ngx_delete_file(name) == NGX_FILE_ERROR) { |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1034 ngx_log_error(NGX_LOG_CRIT, ngx_cycle->log, ngx_errno, |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1035 ngx_delete_file_n " \"%s\" failed", name); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1036 } |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1037 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1038 ngx_shmtx_lock(&cache->shpool->mutex); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1039 } |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1040 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1041 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1042 static time_t |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1043 ngx_http_file_cache_manager(void *data) |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1044 { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1045 ngx_http_file_cache_t *cache = data; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1046 |
3247
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1047 off_t size; |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1048 time_t next; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1049 |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1050 next = ngx_http_file_cache_expire(cache); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1051 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1052 cache->last = ngx_current_msec; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1053 cache->files = 0; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1054 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1055 for ( ;; ) { |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1056 ngx_shmtx_lock(&cache->shpool->mutex); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1057 |
2720
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
1058 size = cache->sh->size; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1059 |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1060 ngx_shmtx_unlock(&cache->shpool->mutex); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1061 |
2631 | 1062 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0, |
1063 "http file cache size: %O", size); | |
1064 | |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1065 if (size < cache->max_size) { |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1066 return next; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1067 } |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1068 |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1069 next = ngx_http_file_cache_forced_expire(cache); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1070 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1071 if (ngx_http_file_cache_manager_sleep(cache) != NGX_OK) { |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1072 return next; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1073 } |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1074 } |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1075 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1076 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1077 |
3247
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1078 static void |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1079 ngx_http_file_cache_loader(void *data) |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1080 { |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1081 ngx_http_file_cache_t *cache = data; |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1082 |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1083 ngx_tree_ctx_t tree; |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1084 |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1085 if (!cache->sh->cold || cache->sh->loading) { |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1086 return; |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1087 } |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1088 |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1089 if (!ngx_atomic_cmp_set(&cache->sh->loading, 0, ngx_pid)) { |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1090 return; |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1091 } |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1092 |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1093 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0, |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1094 "http file cache loader"); |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1095 |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1096 tree.init_handler = NULL; |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1097 tree.file_handler = ngx_http_file_cache_manage_file; |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1098 tree.pre_tree_handler = ngx_http_file_cache_noop; |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1099 tree.post_tree_handler = ngx_http_file_cache_noop; |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1100 tree.spec_handler = ngx_http_file_cache_delete_file; |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1101 tree.data = cache; |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1102 tree.alloc = 0; |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1103 tree.log = ngx_cycle->log; |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1104 |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1105 cache->last = ngx_current_msec; |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1106 cache->files = 0; |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1107 |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1108 if (ngx_walk_tree(&tree, &cache->path->name) == NGX_ABORT) { |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1109 cache->sh->loading = 0; |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1110 return; |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1111 } |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1112 |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1113 cache->sh->cold = 0; |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1114 cache->sh->loading = 0; |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1115 |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1116 ngx_log_error(NGX_LOG_NOTICE, ngx_cycle->log, 0, |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1117 "http file cache: %V %.3fM, bsize: %uz", |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1118 &cache->path->name, |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1119 ((double) cache->sh->size * cache->bsize) / (1024 * 1024), |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1120 cache->bsize); |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1121 } |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1122 |
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1123 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1124 static ngx_int_t |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1125 ngx_http_file_cache_manager_sleep(ngx_http_file_cache_t *cache) |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1126 { |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1127 ngx_msec_t elapsed; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1128 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1129 if (cache->files++ > 100) { |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1130 |
3587
e1409e56ba7c
merge r3473, r3474, r3385, r3386, r3537:
Igor Sysoev <igor@sysoev.ru>
parents:
3439
diff
changeset
|
1131 ngx_time_update(); |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1132 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1133 elapsed = ngx_abs((ngx_msec_int_t) (ngx_current_msec - cache->last)); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1134 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1135 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0, |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1136 "http file cache manager time: %M", elapsed); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1137 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1138 if (elapsed > 200) { |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1139 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1140 /* |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1141 * if processing 100 files takes more than 200ms, |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1142 * it seems that many operations require disk i/o, |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1143 * therefore sleep 200ms |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1144 */ |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1145 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1146 ngx_msleep(200); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1147 |
3587
e1409e56ba7c
merge r3473, r3474, r3385, r3386, r3537:
Igor Sysoev <igor@sysoev.ru>
parents:
3439
diff
changeset
|
1148 ngx_time_update(); |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1149 } |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1150 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1151 cache->last = ngx_current_msec; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1152 cache->files = 0; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1153 } |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1154 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1155 return (ngx_quit || ngx_terminate) ? NGX_ABORT : NGX_OK; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1156 } |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1157 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1158 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1159 static ngx_int_t |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1160 ngx_http_file_cache_noop(ngx_tree_ctx_t *ctx, ngx_str_t *path) |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1161 { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1162 return NGX_OK; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1163 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1164 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1165 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1166 static ngx_int_t |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1167 ngx_http_file_cache_manage_file(ngx_tree_ctx_t *ctx, ngx_str_t *path) |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1168 { |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1169 ngx_http_file_cache_t *cache; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1170 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1171 cache = ctx->data; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1172 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1173 if (ngx_http_file_cache_add_file(ctx, path) != NGX_OK) { |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1174 (void) ngx_http_file_cache_delete_file(ctx, path); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1175 } |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1176 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1177 return ngx_http_file_cache_manager_sleep(cache); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1178 } |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1179 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1180 |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1181 static ngx_int_t |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1182 ngx_http_file_cache_add_file(ngx_tree_ctx_t *ctx, ngx_str_t *name) |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1183 { |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1184 u_char *p; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1185 ngx_fd_t fd; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1186 ngx_int_t n; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1187 ngx_uint_t i; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1188 ngx_file_info_t fi; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1189 ngx_http_cache_t c; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1190 ngx_http_file_cache_t *cache; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1191 ngx_http_file_cache_header_t h; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1192 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1193 if (name->len < 2 * NGX_HTTP_CACHE_KEY_LEN) { |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1194 return NGX_ERROR; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1195 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1196 |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1197 ngx_memzero(&c, sizeof(ngx_http_cache_t)); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1198 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1199 fd = ngx_open_file(name->data, NGX_FILE_RDONLY, NGX_FILE_OPEN, 0); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1200 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1201 if (fd == NGX_INVALID_FILE) { |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1202 ngx_log_error(NGX_LOG_CRIT, ctx->log, ngx_errno, |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1203 ngx_open_file_n " \"%s\" failed", name->data); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1204 return NGX_ERROR; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1205 } |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1206 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1207 c.file.fd = fd; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1208 c.file.name = *name; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1209 c.file.log = ctx->log; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1210 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1211 n = ngx_read_file(&c.file, (u_char *) &h, |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1212 sizeof(ngx_http_file_cache_header_t), 0); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1213 if (n == NGX_ERROR) { |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1214 return NGX_ERROR; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1215 } |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1216 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1217 if ((size_t) n < sizeof(ngx_http_file_cache_header_t)) { |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1218 ngx_log_error(NGX_LOG_CRIT, ctx->log, 0, |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1219 "cache file \"%s\" is too small", name->data); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1220 return NGX_ERROR; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1221 } |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1222 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1223 if (ngx_fd_info(fd, &fi) == NGX_FILE_ERROR) { |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1224 ngx_log_error(NGX_LOG_CRIT, ctx->log, ngx_errno, |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1225 ngx_fd_info_n " \"%s\" failed", name->data); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1226 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1227 } else { |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1228 c.uniq = ngx_file_uniq(&fi); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1229 c.valid_sec = h.valid_sec; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1230 c.valid_msec = h.valid_msec; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1231 c.body_start = h.body_start; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1232 c.length = ngx_file_size(&fi); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1233 } |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1234 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1235 if (ngx_close_file(fd) == NGX_FILE_ERROR) { |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1236 ngx_log_error(NGX_LOG_ALERT, ctx->log, ngx_errno, |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1237 ngx_close_file_n " \"%s\" failed", name->data); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1238 } |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1239 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1240 if (c.body_start == 0) { |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1241 return NGX_ERROR; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1242 } |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1243 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1244 p = &name->data[name->len - 2 * NGX_HTTP_CACHE_KEY_LEN]; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1245 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1246 for (i = 0; i < NGX_HTTP_CACHE_KEY_LEN; i++) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1247 n = ngx_hextoi(p, 2); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1248 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1249 if (n == NGX_ERROR) { |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1250 return NGX_ERROR; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1251 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1252 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1253 p += 2; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1254 |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1255 c.key[i] = (u_char) n; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1256 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1257 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1258 cache = ctx->data; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1259 |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1260 return ngx_http_file_cache_add(cache, &c); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1261 } |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1262 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1263 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1264 static ngx_int_t |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1265 ngx_http_file_cache_add(ngx_http_file_cache_t *cache, ngx_http_cache_t *c) |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1266 { |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1267 ngx_http_file_cache_node_t *fcn; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1268 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1269 ngx_shmtx_lock(&cache->shpool->mutex); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1270 |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1271 fcn = ngx_http_file_cache_lookup(cache, c->key); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1272 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1273 if (fcn == NULL) { |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1274 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1275 fcn = ngx_slab_alloc_locked(cache->shpool, |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1276 sizeof(ngx_http_file_cache_node_t)); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1277 if (fcn == NULL) { |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1278 ngx_shmtx_unlock(&cache->shpool->mutex); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1279 return NGX_ERROR; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1280 } |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1281 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1282 ngx_memcpy((u_char *) &fcn->node.key, c->key, sizeof(ngx_rbtree_key_t)); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1283 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1284 ngx_memcpy(fcn->key, &c->key[sizeof(ngx_rbtree_key_t)], |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1285 NGX_HTTP_CACHE_KEY_LEN - sizeof(ngx_rbtree_key_t)); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1286 |
2720
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
1287 ngx_rbtree_insert(&cache->sh->rbtree, &fcn->node); |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1288 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1289 fcn->uses = 1; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1290 fcn->count = 0; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1291 fcn->valid_msec = c->valid_msec; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1292 fcn->error = 0; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1293 fcn->exists = 1; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1294 fcn->uniq = c->uniq; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1295 fcn->valid_sec = c->valid_sec; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1296 fcn->body_start = c->body_start; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1297 fcn->length = c->length; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1298 |
2720
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
1299 cache->sh->size += (c->length + cache->bsize - 1) / cache->bsize; |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1300 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1301 } else { |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1302 ngx_queue_remove(&fcn->queue); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1303 } |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1304 |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1305 fcn->expire = ngx_time() + cache->inactive; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1306 |
2720
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
1307 ngx_queue_insert_head(&cache->sh->queue, &fcn->queue); |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1308 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1309 ngx_shmtx_unlock(&cache->shpool->mutex); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1310 |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1311 return NGX_OK; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1312 } |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1313 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1314 |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1315 static ngx_int_t |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1316 ngx_http_file_cache_delete_file(ngx_tree_ctx_t *ctx, ngx_str_t *path) |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1317 { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1318 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ctx->log, 0, |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1319 "http file cache delete: \"%s\"", path->data); |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1320 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1321 if (ngx_delete_file(path->data) == NGX_FILE_ERROR) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1322 ngx_log_error(NGX_LOG_CRIT, ctx->log, ngx_errno, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1323 ngx_delete_file_n " \"%s\" failed", path->data); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1324 } |
477 | 1325 |
202
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1326 return NGX_OK; |
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1327 } |
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1328 |
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1329 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1330 time_t |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1331 ngx_http_file_cache_valid(ngx_array_t *cache_valid, ngx_uint_t status) |
202
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1332 { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1333 ngx_uint_t i; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1334 ngx_http_cache_valid_t *valid; |
202
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1335 |
2626
b0cfe5f66e8d
fix segfault introduced in r2602 if there is 502/504 error
Igor Sysoev <igor@sysoev.ru>
parents:
2616
diff
changeset
|
1336 if (cache_valid == NULL) { |
b0cfe5f66e8d
fix segfault introduced in r2602 if there is 502/504 error
Igor Sysoev <igor@sysoev.ru>
parents:
2616
diff
changeset
|
1337 return 0; |
b0cfe5f66e8d
fix segfault introduced in r2602 if there is 502/504 error
Igor Sysoev <igor@sysoev.ru>
parents:
2616
diff
changeset
|
1338 } |
b0cfe5f66e8d
fix segfault introduced in r2602 if there is 502/504 error
Igor Sysoev <igor@sysoev.ru>
parents:
2616
diff
changeset
|
1339 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1340 valid = cache_valid->elts; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1341 for (i = 0; i < cache_valid->nelts; i++) { |
202
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1342 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1343 if (valid[i].status == 0) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1344 return valid[i].valid; |
202
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1345 } |
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1346 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1347 if (valid[i].status == status) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1348 return valid[i].valid; |
202
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1349 } |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1350 } |
202
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1351 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1352 return 0; |
202
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1353 } |
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1354 |
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1355 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1356 char * |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1357 ngx_http_file_cache_set_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1358 { |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1359 off_t max_size; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1360 u_char *last, *p; |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1361 time_t inactive; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1362 ssize_t size; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1363 ngx_str_t s, name, *value; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1364 ngx_uint_t i, n; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1365 ngx_http_file_cache_t *cache; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1366 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1367 cache = ngx_pcalloc(cf->pool, sizeof(ngx_http_file_cache_t)); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1368 if (cache == NULL) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1369 return NGX_CONF_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1370 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1371 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1372 cache->path = ngx_pcalloc(cf->pool, sizeof(ngx_path_t)); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1373 if (cache->path == NULL) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1374 return NGX_CONF_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1375 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1376 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1377 inactive = 600; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1378 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1379 name.len = 0; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1380 size = 0; |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1381 max_size = NGX_MAX_OFF_T_VALUE; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1382 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1383 value = cf->args->elts; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1384 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1385 cache->path->name = value[1]; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1386 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1387 if (cache->path->name.data[cache->path->name.len - 1] == '/') { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1388 cache->path->name.len--; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1389 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1390 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1391 if (ngx_conf_full_name(cf->cycle, &cache->path->name, 0) != NGX_OK) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1392 return NGX_CONF_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1393 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1394 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1395 for (i = 2; i < cf->args->nelts; i++) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1396 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1397 if (ngx_strncmp(value[i].data, "levels=", 7) == 0) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1398 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1399 p = value[i].data + 7; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1400 last = value[i].data + value[i].len; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1401 |
2671 | 1402 for (n = 0; n < 3 && p < last; n++) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1403 |
2671 | 1404 if (*p > '0' && *p < '3') { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1405 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1406 cache->path->level[n] = *p++ - '0'; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1407 cache->path->len += cache->path->level[n] + 1; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1408 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1409 if (p == last) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1410 break; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1411 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1412 |
2671 | 1413 if (*p++ == ':' && n < 2 && p != last) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1414 continue; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1415 } |
2671 | 1416 |
1417 goto invalid_levels; | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1418 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1419 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1420 goto invalid_levels; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1421 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1422 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1423 if (cache->path->len < 10 + 3) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1424 continue; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1425 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1426 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1427 invalid_levels: |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1428 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1429 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1430 "invalid \"levels\" \"%V\"", &value[i]); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1431 return NGX_CONF_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1432 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1433 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1434 if (ngx_strncmp(value[i].data, "keys_zone=", 10) == 0) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1435 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1436 name.data = value[i].data + 10; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1437 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1438 p = (u_char *) ngx_strchr(name.data, ':'); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1439 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1440 if (p) { |
2716
d5896f6608e8
move zone name from ngx_shm_zone_t to ngx_shm_t to use Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2694
diff
changeset
|
1441 *p = '\0'; |
d5896f6608e8
move zone name from ngx_shm_zone_t to ngx_shm_t to use Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2694
diff
changeset
|
1442 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1443 name.len = p - name.data; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1444 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1445 p++; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1446 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1447 s.len = value[i].data + value[i].len - p; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1448 s.data = p; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1449 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1450 size = ngx_parse_size(&s); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1451 if (size > 8191) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1452 continue; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1453 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1454 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1455 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1456 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1457 "invalid keys zone size \"%V\"", &value[i]); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1458 return NGX_CONF_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1459 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1460 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1461 if (ngx_strncmp(value[i].data, "inactive=", 9) == 0) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1462 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1463 s.len = value[i].len - 9; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1464 s.data = value[i].data + 9; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1465 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1466 inactive = ngx_parse_time(&s, 1); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1467 if (inactive < 0) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1468 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1469 "invalid inactive value \"%V\"", &value[i]); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1470 return NGX_CONF_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1471 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1472 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1473 continue; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1474 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1475 |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1476 if (ngx_strncmp(value[i].data, "max_size=", 9) == 0) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1477 |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1478 s.len = value[i].len - 9; |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1479 s.data = value[i].data + 9; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1480 |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1481 max_size = ngx_parse_offset(&s); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1482 if (max_size < 0) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1483 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1484 "invalid max_size value \"%V\"", &value[i]); |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1485 return NGX_CONF_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1486 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1487 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1488 continue; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1489 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1490 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1491 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1492 "invalid parameter \"%V\"", &value[i]); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1493 return NGX_CONF_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1494 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1495 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1496 if (name.len == 0 || size == 0) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1497 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1498 "\"%V\" must have \"keys_zone\" parameter", |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1499 &cmd->name); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1500 return NGX_CONF_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1501 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1502 |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1503 cache->path->manager = ngx_http_file_cache_manager; |
3247
1f3cd08ebb82
merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196:
Igor Sysoev <igor@sysoev.ru>
parents:
3092
diff
changeset
|
1504 cache->path->loader = ngx_http_file_cache_loader; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1505 cache->path->data = cache; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1506 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1507 if (ngx_add_path(cf, &cache->path) != NGX_OK) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1508 return NGX_CONF_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1509 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1510 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1511 cache->shm_zone = ngx_shared_memory_add(cf, &name, size, cmd->post); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1512 if (cache->shm_zone == NULL) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1513 return NGX_CONF_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1514 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1515 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1516 if (cache->shm_zone->data) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1517 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1518 "duplicate zone \"%V\"", &name); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1519 return NGX_CONF_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1520 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1521 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1522 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1523 cache->shm_zone->init = ngx_http_file_cache_init; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1524 cache->shm_zone->data = cache; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1525 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1526 cache->inactive = inactive; |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2611
diff
changeset
|
1527 cache->max_size = max_size; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1528 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1529 return NGX_CONF_OK; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1530 } |
477 | 1531 |
1532 | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1533 char * |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1534 ngx_http_file_cache_valid_set_slot(ngx_conf_t *cf, ngx_command_t *cmd, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1535 void *conf) |
202
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1536 { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1537 char *p = conf; |
202
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1538 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1539 time_t valid; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1540 ngx_str_t *value; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1541 ngx_uint_t i, n, status; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1542 ngx_array_t **a; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1543 ngx_http_cache_valid_t *v; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1544 static ngx_uint_t statuses[] = { 200, 301, 302 }; |
477 | 1545 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1546 a = (ngx_array_t **) (p + cmd->offset); |
202
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1547 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1548 if (*a == NGX_CONF_UNSET_PTR) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1549 *a = ngx_array_create(cf->pool, 1, sizeof(ngx_http_cache_valid_t)); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1550 if (*a == NULL) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1551 return NGX_CONF_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1552 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1553 } |
202
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1554 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1555 value = cf->args->elts; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1556 n = cf->args->nelts - 1; |
202
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1557 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1558 valid = ngx_parse_time(&value[n], 1); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1559 if (valid < 0) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1560 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1561 "invalid time value \"%V\"", &value[n]); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1562 return NGX_CONF_ERROR; |
202
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1563 } |
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1564 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1565 if (n == 1) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1566 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1567 for (i = 0; i < 3; i++) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1568 v = ngx_array_push(*a); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1569 if (v == NULL) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1570 return NGX_CONF_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1571 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1572 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1573 v->status = statuses[i]; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1574 v->valid = valid; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1575 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1576 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1577 return NGX_CONF_OK; |
202
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1578 } |
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1579 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1580 for (i = 1; i < n; i++) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1581 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1582 if (ngx_strcmp(value[i].data, "any") == 0) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1583 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1584 status = 0; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1585 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1586 } else { |
202
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1587 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1588 status = ngx_atoi(value[i].data, value[i].len); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1589 if (status < 100) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1590 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1591 "invalid status \"%V\"", &value[i]); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1592 return NGX_CONF_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1593 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1594 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1595 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1596 v = ngx_array_push(*a); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1597 if (v == NULL) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1598 return NGX_CONF_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1599 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1600 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1601 v->status = status; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1602 v->valid = valid; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1603 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1604 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
633
diff
changeset
|
1605 return NGX_CONF_OK; |
202
74994aeef848
nginx-0.0.1-2003-12-01-19:28:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1606 } |