diff options
author | Igor Sysoev <igor@sysoev.ru> | 2003-11-18 21:34:08 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2003-11-18 21:34:08 +0000 |
commit | 1b138ed141c0bdb0c9944c1ae70e53682ed2d035 (patch) | |
tree | c5b4cabecced530570f4a2d6a93cc7d5fc8e044e /src/core/ngx_garbage_collector.c | |
parent | 222a2adf40eb25ff613c251f15032f1e39d7f609 (diff) | |
download | nginx-1b138ed141c0bdb0c9944c1ae70e53682ed2d035.tar.gz nginx-1b138ed141c0bdb0c9944c1ae70e53682ed2d035.zip |
nginx-0.0.1-2003-11-19-00:34:08 import
Diffstat (limited to 'src/core/ngx_garbage_collector.c')
-rw-r--r-- | src/core/ngx_garbage_collector.c | 53 |
1 files changed, 17 insertions, 36 deletions
diff --git a/src/core/ngx_garbage_collector.c b/src/core/ngx_garbage_collector.c index 087b0ad0c..e673acd5a 100644 --- a/src/core/ngx_garbage_collector.c +++ b/src/core/ngx_garbage_collector.c @@ -1,24 +1,11 @@ #include <ngx_config.h> #include <ngx_core.h> +#include <ngx_garbage_collector.h> -typedef struct ngx_gc_s ngx_gc_t; - -typedef int (*ngx_gc_handler_pt) (ngx_gc_t *ctx, ngx_str_t *name, - ngx_dir_t *dir); - - -static int ngx_garbage_collector_temp_handler(ngx_gc_t *ctx, ngx_str_t *name, - ngx_dir_t *dir); - -struct ngx_gc_s { - ngx_path_t *path; - u_int deleted; - off_t freed; - ngx_gc_handler_pt handler; - ngx_log_t *log; -}; +int ngx_garbage_collector_temp_handler(ngx_gc_t *ctx, ngx_str_t *name, + ngx_dir_t *dir); static int ngx_collect_garbage(ngx_gc_t *ctx, ngx_str_t *dname, int level); @@ -64,27 +51,20 @@ void garbage_collector() #endif -void stub_init(ngx_log_t *log) +void stub_init(ngx_cycle_t *cycle) { - ngx_gc_t *ctx; - ngx_path_t path; + int i; + ngx_gc_t ctx; + ngx_path_t **path; - if (!(ctx = ngx_alloc(sizeof(ngx_gc_t), log))) { - return; - } + path = cycle->pathes.elts; + for (i = 0; i < cycle->pathes.nelts; i++) { + ctx.path = path[i]; + ctx.log = cycle->log; + ctx.handler = path[i]->gc_handler; - path.name.len = 4; - path.name.data = "temp"; - path.len = 5; - path.level[0] = 1; - path.level[1] = 2; - path.level[2] = 0; - - ctx->path = &path; - ctx->log = log; - ctx->handler = ngx_garbage_collector_temp_handler; - - ngx_collect_garbage(ctx, &path.name, 0); + ngx_collect_garbage(&ctx, &path[i]->name, 0); + } } @@ -254,8 +234,8 @@ ngx_log_debug(ctx->log, "file %s" _ fname.data); } -static int ngx_garbage_collector_temp_handler(ngx_gc_t *ctx, ngx_str_t *name, - ngx_dir_t *dir) +int ngx_garbage_collector_temp_handler(ngx_gc_t *ctx, ngx_str_t *name, + ngx_dir_t *dir) { /* * we use mtime only and do not use atime because: @@ -279,5 +259,6 @@ static int ngx_garbage_collector_temp_handler(ngx_gc_t *ctx, ngx_str_t *name, ctx->deleted++; ctx->freed += ngx_de_size(dir); + return NGX_OK; } |