Mercurial > hg > nginx
comparison src/core/ngx_garbage_collector.c @ 257:70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 11 Feb 2004 17:08:49 +0000 |
parents | 2357fa41738a |
children | 87e73f067470 |
comparison
equal
deleted
inserted
replaced
256:8e39cab6abd5 | 257:70e1c7d2b83d |
---|---|
77 ngx_str_t fname, buf; | 77 ngx_str_t fname, buf; |
78 ngx_dir_t dir; | 78 ngx_dir_t dir; |
79 | 79 |
80 buf.len = 0; | 80 buf.len = 0; |
81 | 81 |
82 ngx_log_debug(ctx->log, "dir '%s':%d" _ dname->data _ dname->len); | 82 ngx_log_debug2(NGX_LOG_DEBUG_CORE, ctx->log, 0, |
83 "gc dir \"%s\":%d", dname->data, dname->len); | |
83 | 84 |
84 if (ngx_open_dir(dname, &dir) == NGX_ERROR) { | 85 if (ngx_open_dir(dname, &dir) == NGX_ERROR) { |
85 ngx_log_error(NGX_LOG_CRIT, ctx->log, ngx_errno, | 86 ngx_log_error(NGX_LOG_CRIT, ctx->log, ngx_errno, |
86 ngx_open_dir_n " \"%s\" failed", dname->data); | 87 ngx_open_dir_n " \"%s\" failed", dname->data); |
87 return NGX_ERROR; | 88 return NGX_ERROR; |
104 break; | 105 break; |
105 } | 106 } |
106 | 107 |
107 len = ngx_de_namelen(&dir); | 108 len = ngx_de_namelen(&dir); |
108 | 109 |
109 ngx_log_debug(ctx->log, "name '%s':%d" _ ngx_de_name(&dir) _ len); | 110 ngx_log_debug2(NGX_LOG_DEBUG_CORE, ctx->log, 0, |
111 "gc name \"%s\":%d", ngx_de_name(&dir), len); | |
110 | 112 |
111 if (len == 1 && ngx_de_name(&dir)[0] == '.') { | 113 if (len == 1 && ngx_de_name(&dir)[0] == '.') { |
112 continue; | 114 continue; |
113 } | 115 } |
114 | 116 |
137 last = ngx_cpymem(buf.data, dname->data, dname->len); | 139 last = ngx_cpymem(buf.data, dname->data, dname->len); |
138 *last++ = '/'; | 140 *last++ = '/'; |
139 ngx_memcpy(last, ngx_de_name(&dir), len + 1); | 141 ngx_memcpy(last, ngx_de_name(&dir), len + 1); |
140 fname.data = buf.data; | 142 fname.data = buf.data; |
141 | 143 |
142 ngx_log_debug(ctx->log, "path %s" _ fname.data); | 144 ngx_log_debug1(NGX_LOG_DEBUG_CORE, ctx->log, 0, |
145 "gc path: \"%s\"", fname.data); | |
143 | 146 |
144 if (!dir.info_valid) { | 147 if (!dir.info_valid) { |
145 if (ngx_de_info(fname.data, &dir) == NGX_FILE_ERROR) { | 148 if (ngx_de_info(fname.data, &dir) == NGX_FILE_ERROR) { |
146 ngx_log_error(NGX_LOG_CRIT, ctx->log, ngx_errno, | 149 ngx_log_error(NGX_LOG_CRIT, ctx->log, ngx_errno, |
147 ngx_de_info_n " \"%s\" failed", fname.data); | 150 ngx_de_info_n " \"%s\" failed", fname.data); |
149 } | 152 } |
150 } | 153 } |
151 | 154 |
152 if (ngx_de_is_dir(&dir)) { | 155 if (ngx_de_is_dir(&dir)) { |
153 | 156 |
154 ngx_log_debug(ctx->log, "enter %s" _ fname.data); | 157 ngx_log_debug1(NGX_LOG_DEBUG_CORE, ctx->log, 0, |
158 "gc enter dir \"%s\"", fname.data); | |
155 | 159 |
156 if (level == -1 | 160 if (level == -1 |
157 /* there can not be directory on the last level */ | 161 /* there can not be directory on the last level */ |
158 || level == NGX_MAX_PATH_LEVEL | 162 || level == NGX_MAX_PATH_LEVEL |
159 /* an directory from the old path hierarchy */ | 163 /* an directory from the old path hierarchy */ |
185 return NGX_ABORT; | 189 return NGX_ABORT; |
186 } | 190 } |
187 | 191 |
188 } else if (ngx_de_is_file(&dir)) { | 192 } else if (ngx_de_is_file(&dir)) { |
189 | 193 |
190 ngx_log_debug(ctx->log, "file %s" _ fname.data); | 194 ngx_log_debug1(NGX_LOG_DEBUG_CORE, ctx->log, 0, |
195 "gc file \"%s\"", fname.data); | |
191 | 196 |
192 if (level == -1 | 197 if (level == -1 |
193 || (level < NGX_MAX_PATH_LEVEL && ctx->path->level[level] != 0)) | 198 || (level < NGX_MAX_PATH_LEVEL && ctx->path->level[level] != 0)) |
194 { | 199 { |
195 if (ngx_delete_file(fname.data) == NGX_FILE_ERROR) { | 200 if (ngx_delete_file(fname.data) == NGX_FILE_ERROR) { |
237 | 242 |
238 int ngx_garbage_collector_temp_handler(ngx_gc_t *ctx, ngx_str_t *name, | 243 int ngx_garbage_collector_temp_handler(ngx_gc_t *ctx, ngx_str_t *name, |
239 ngx_dir_t *dir) | 244 ngx_dir_t *dir) |
240 { | 245 { |
241 /* | 246 /* |
242 * we use mtime only and do not use atime because: | 247 * We use mtime only and do not use atime because: |
243 * on NTFS access time has a resolution of 1 hour, | 248 * on NTFS access time has a resolution of 1 hour, |
244 * on NT FAT access time has a resolution of 1 day, | 249 * on NT FAT access time has a resolution of 1 day, |
245 * Unices have mount option "noatime" | 250 * Unices have the mount option "noatime". |
246 */ | 251 */ |
247 | 252 |
248 if (ngx_cached_time - ngx_de_mtime(dir) < 3600) { | 253 if (ngx_cached_time - ngx_de_mtime(dir) < 3600) { |
249 return NGX_OK; | 254 return NGX_OK; |
250 } | 255 } |