Mercurial > hg > nginx
comparison src/core/ngx_garbage_collector.c @ 467:bbd6b0b4a2b1 release-0.1.8
nginx-0.1.8-RELEASE import
*) Bugfix: in the ngx_http_autoindex_module if the long file names were
in the listing.
*) Feature: the "^~" modifier in the location directive.
*) Feature: the proxy_max_temp_file_size directive.
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sat, 20 Nov 2004 19:52:20 +0000 |
parents | ded1284520cc |
children | 64d9afb209da |
comparison
equal
deleted
inserted
replaced
466:ee6d66462bff | 467:bbd6b0b4a2b1 |
---|---|
7 #include <ngx_config.h> | 7 #include <ngx_config.h> |
8 #include <ngx_core.h> | 8 #include <ngx_core.h> |
9 #include <ngx_garbage_collector.h> | 9 #include <ngx_garbage_collector.h> |
10 | 10 |
11 | 11 |
12 int ngx_garbage_collector_temp_handler(ngx_gc_t *ctx, ngx_str_t *name, | 12 |
13 ngx_dir_t *dir); | 13 ngx_int_t ngx_collect_garbage(ngx_gc_t *ctx, ngx_str_t *dname, int level) |
14 | |
15 | |
16 static int ngx_collect_garbage(ngx_gc_t *ctx, ngx_str_t *dname, int level); | |
17 | |
18 | |
19 | |
20 #if 0 | |
21 | |
22 { | |
23 ngx_test_null(cycle->timer_events, | |
24 ngx_alloc(sizeof(ngx_event_t) * TIMERS, cycle->log), | |
25 NGX_ERROR); | |
26 | |
27 ngx_event_timer_init(cycle); | |
28 } | |
29 | |
30 | |
31 void garbage_collector() | |
32 { | |
33 ngx_msec_t timer; | |
34 struct timeval tv; | |
35 ngx_epoch_msec_t delta; | |
36 | |
37 for ( ;; ) { | |
38 timer = ngx_event_find_timer(); | |
39 | |
40 ngx_gettimeofday(&tv); | |
41 delta = tv.tv_sec * 1000 + tv.tv_usec / 1000; | |
42 | |
43 msleep(timer); | |
44 | |
45 ngx_gettimeofday(&tv); | |
46 | |
47 ngx_cached_time = tv.tv_sec; | |
48 ngx_time_update(); | |
49 | |
50 delta = tv.tv_sec * 1000 + tv.tv_usec / 1000 - delta; | |
51 | |
52 ngx_event_expire_timers((ngx_msec_t) delta); | |
53 } | |
54 } | |
55 | |
56 #endif | |
57 | |
58 | |
59 void stub_init(ngx_cycle_t *cycle) | |
60 { | |
61 ngx_uint_t i; | |
62 ngx_gc_t ctx; | |
63 ngx_path_t **path; | |
64 | |
65 path = cycle->pathes.elts; | |
66 for (i = 0; i < cycle->pathes.nelts; i++) { | |
67 ctx.path = path[i]; | |
68 ctx.log = cycle->log; | |
69 ctx.handler = path[i]->gc_handler; | |
70 | |
71 ngx_collect_garbage(&ctx, &path[i]->name, 0); | |
72 } | |
73 } | |
74 | |
75 | |
76 static int ngx_collect_garbage(ngx_gc_t *ctx, ngx_str_t *dname, int level) | |
77 { | 14 { |
78 int rc; | 15 int rc; |
79 u_char *last; | 16 u_char *last; |
80 size_t len; | 17 size_t len; |
81 ngx_err_t err; | 18 ngx_err_t err; |
222 return NGX_ABORT; | 159 return NGX_ABORT; |
223 } | 160 } |
224 | 161 |
225 } else { | 162 } else { |
226 ngx_log_error(NGX_LOG_CRIT, ctx->log, ngx_errno, | 163 ngx_log_error(NGX_LOG_CRIT, ctx->log, ngx_errno, |
227 "\"%s\" has unknown file type, deleting", fname.data); | 164 "the file \"%s\" has unknown type, deleting", |
165 fname.data); | |
228 | 166 |
229 if (ngx_delete_file(fname.data) == NGX_FILE_ERROR) { | 167 if (ngx_delete_file(fname.data) == NGX_FILE_ERROR) { |
230 ngx_log_error(NGX_LOG_CRIT, ctx->log, ngx_errno, | 168 ngx_log_error(NGX_LOG_CRIT, ctx->log, ngx_errno, |
231 ngx_delete_file_n " \"%s\" failed", fname.data); | 169 ngx_delete_file_n " \"%s\" failed", fname.data); |
232 } else { | 170 } else { |
247 | 185 |
248 return rc; | 186 return rc; |
249 } | 187 } |
250 | 188 |
251 | 189 |
252 int ngx_garbage_collector_temp_handler(ngx_gc_t *ctx, ngx_str_t *name, | 190 ngx_int_t ngx_garbage_collector_temp_handler(ngx_gc_t *ctx, ngx_str_t *name, |
253 ngx_dir_t *dir) | 191 ngx_dir_t *dir) |
254 { | 192 { |
255 /* | 193 /* |
256 * We use mtime only and do not use atime because: | 194 * We use mtime only and do not use atime because: |
257 * on NTFS access time has a resolution of 1 hour, | 195 * on NTFS access time has a resolution of 1 hour, |
258 * on NT FAT access time has a resolution of 1 day, | 196 * on NT FAT access time has a resolution of 1 day, |
262 if (ngx_time() - ngx_de_mtime(dir) < 3600) { | 200 if (ngx_time() - ngx_de_mtime(dir) < 3600) { |
263 return NGX_OK; | 201 return NGX_OK; |
264 } | 202 } |
265 | 203 |
266 ngx_log_error(NGX_LOG_NOTICE, ctx->log, 0, | 204 ngx_log_error(NGX_LOG_NOTICE, ctx->log, 0, |
267 "delete stale temporary \"%s\"", name->data); | 205 "delete the stale temporary file \"%s\"", name->data); |
268 | 206 |
269 if (ngx_delete_file(name->data) == NGX_FILE_ERROR) { | 207 if (ngx_delete_file(name->data) == NGX_FILE_ERROR) { |
270 ngx_log_error(NGX_LOG_CRIT, ctx->log, ngx_errno, | 208 ngx_log_error(NGX_LOG_CRIT, ctx->log, ngx_errno, |
271 ngx_delete_file_n " \"%s\" failed", name->data); | 209 ngx_delete_file_n " \"%s\" failed", name->data); |
272 return NGX_ERROR; | 210 return NGX_ERROR; |