aboutsummaryrefslogtreecommitdiffstats
path: root/cache.c
diff options
context:
space:
mode:
authorLukas Fleischer <cgit@cryptocrack.de>2014-01-15 21:53:15 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2014-01-17 00:44:54 +0100
commitf60ffa143cca61e9729ac71033e1a556cf422871 (patch)
treeff9122fef2779ddea8e37806cc66dc67b63df99f /cache.c
parenta431326e8fab8153905fbde036dd3c9fb4cc8eaa (diff)
Switch to exclusively using global ctx
Drop the context parameter from the following functions (and all static helpers used by them) and use the global context instead: * cgit_print_http_headers() * cgit_print_docstart() * cgit_print_pageheader() Remove context parameter from all commands Drop the context parameter from the following functions (and all static helpers used by them) and use the global context instead: * cgit_get_cmd() * All cgit command functions. * cgit_clone_info() * cgit_clone_objects() * cgit_clone_head() * cgit_print_plain() * cgit_show_stats() In initialization routines, use the global context variable instead of passing a pointer around locally. Remove callback data parameter for cache slots This is no longer needed since the context is always read from the global context variable. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
Diffstat (limited to 'cache.c')
-rw-r--r--cache.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/cache.c b/cache.c
index fa83ddc..fcd461f 100644
--- a/cache.c
+++ b/cache.c
@@ -24,7 +24,6 @@ struct cache_slot {
int keylen;
int ttl;
cache_fill_fn fn;
- void *cbdata;
int cache_fd;
int lock_fd;
const char *cache_name;
@@ -187,7 +186,7 @@ static int fill_slot(struct cache_slot *slot)
return errno;
/* Generate cache content */
- slot->fn(slot->cbdata);
+ slot->fn();
/* Restore stdout */
if (dup2(tmp, STDOUT_FILENO) == -1)
@@ -277,7 +276,7 @@ static int process_slot(struct cache_slot *slot)
if ((err = lock_slot(slot)) != 0) {
cache_log("[cgit] Unable to lock slot %s: %s (%d)\n",
slot->lock_name, strerror(err), err);
- slot->fn(slot->cbdata);
+ slot->fn();
return 0;
}
@@ -286,7 +285,7 @@ static int process_slot(struct cache_slot *slot)
slot->lock_name, strerror(err), err);
unlock_slot(slot, 0);
close_lock(slot);
- slot->fn(slot->cbdata);
+ slot->fn();
return 0;
}
// We've got a valid cache slot in the lock file, which
@@ -310,7 +309,7 @@ static int process_slot(struct cache_slot *slot)
/* Print cached content to stdout, generate the content if necessary. */
int cache_process(int size, const char *path, const char *key, int ttl,
- cache_fill_fn fn, void *cbdata)
+ cache_fill_fn fn)
{
unsigned long hash;
int i;
@@ -321,14 +320,14 @@ int cache_process(int size, const char *path, const char *key, int ttl,
/* If the cache is disabled, just generate the content */
if (size <= 0) {
- fn(cbdata);
+ fn();
return 0;
}
/* Verify input, calculate filenames */
if (!path) {
cache_log("[cgit] Cache path not specified, caching is disabled\n");
- fn(cbdata);
+ fn();
return 0;
}
if (!key)
@@ -343,7 +342,6 @@ int cache_process(int size, const char *path, const char *key, int ttl,
strbuf_addbuf(&lockname, &filename);
strbuf_addstr(&lockname, ".lock");
slot.fn = fn;
- slot.cbdata = cbdata;
slot.ttl = ttl;
slot.cache_name = filename.buf;
slot.lock_name = lockname.buf;