diff options
author | Lars Hjemli | 2008-02-16 13:07:13 +0100 |
---|---|---|
committer | Lars Hjemli | 2008-02-16 13:10:50 +0100 |
commit | b228d4ff82a65fdcd4a7364759fe36a0bdda5978 (patch) | |
tree | 33b8cc2ff48113f8d7ad3ba88c7ea19a7cac570a /cache.c | |
parent | d14d77fe95c3b6224b40df9b101dded0deea913c (diff) | |
download | cgit-b228d4ff82a65fdcd4a7364759fe36a0bdda5978.tar.gz cgit-b228d4ff82a65fdcd4a7364759fe36a0bdda5978.tar.bz2 cgit-b228d4ff82a65fdcd4a7364759fe36a0bdda5978.zip |
Add all config variables into struct cgit_context
This removes another big set of global variables, and introduces the
cgit_prepare_context() function which populates a context-variable with
compile-time default values.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to 'cache.c')
-rw-r--r-- | cache.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -44,21 +44,21 @@ int cache_create_dirs() | |||
44 | { | 44 | { |
45 | char *path; | 45 | char *path; |
46 | 46 | ||
47 | path = fmt("%s", cgit_cache_root); | 47 | path = fmt("%s", ctx.cfg.cache_root); |
48 | if (mkdir(path, S_IRWXU) && errno!=EEXIST) | 48 | if (mkdir(path, S_IRWXU) && errno!=EEXIST) |
49 | return 0; | 49 | return 0; |
50 | 50 | ||
51 | if (!cgit_repo) | 51 | if (!cgit_repo) |
52 | return 0; | 52 | return 0; |
53 | 53 | ||
54 | path = fmt("%s/%s", cgit_cache_root, | 54 | path = fmt("%s/%s", ctx.cfg.cache_root, |
55 | cache_safe_filename(cgit_repo->url)); | 55 | cache_safe_filename(cgit_repo->url)); |
56 | 56 | ||
57 | if (mkdir(path, S_IRWXU) && errno!=EEXIST) | 57 | if (mkdir(path, S_IRWXU) && errno!=EEXIST) |
58 | return 0; | 58 | return 0; |
59 | 59 | ||
60 | if (ctx.qry.page) { | 60 | if (ctx.qry.page) { |
61 | path = fmt("%s/%s/%s", cgit_cache_root, | 61 | path = fmt("%s/%s/%s", ctx.cfg.cache_root, |
62 | cache_safe_filename(cgit_repo->url), | 62 | cache_safe_filename(cgit_repo->url), |
63 | ctx.qry.page); | 63 | ctx.qry.page); |
64 | if (mkdir(path, S_IRWXU) && errno!=EEXIST) | 64 | if (mkdir(path, S_IRWXU) && errno!=EEXIST) |
@@ -74,7 +74,7 @@ int cache_refill_overdue(const char *lockfile) | |||
74 | if (stat(lockfile, &st)) | 74 | if (stat(lockfile, &st)) |
75 | return 0; | 75 | return 0; |
76 | else | 76 | else |
77 | return (time(NULL) - st.st_mtime > cgit_cache_max_create_time); | 77 | return (time(NULL) - st.st_mtime > ctx.cfg.cache_max_create_time); |
78 | } | 78 | } |
79 | 79 | ||
80 | int cache_lock(struct cacheitem *item) | 80 | int cache_lock(struct cacheitem *item) |
@@ -83,7 +83,7 @@ int cache_lock(struct cacheitem *item) | |||
83 | char *lockfile = xstrdup(fmt("%s.lock", item->name)); | 83 | char *lockfile = xstrdup(fmt("%s.lock", item->name)); |
84 | 84 | ||
85 | top: | 85 | top: |
86 | if (++i > cgit_max_lock_attempts) | 86 | if (++i > ctx.cfg.max_lock_attempts) |
87 | die("cache_lock: unable to lock %s: %s", | 87 | die("cache_lock: unable to lock %s: %s", |
88 | item->name, strerror(errno)); | 88 | item->name, strerror(errno)); |
89 | 89 | ||