aboutsummaryrefslogtreecommitdiffstats
path: root/cache.c
diff options
context:
space:
mode:
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 {
24 int keylen; 24 int keylen;
25 int ttl; 25 int ttl;
26 cache_fill_fn fn; 26 cache_fill_fn fn;
27 void *cbdata;
28 int cache_fd; 27 int cache_fd;
29 int lock_fd; 28 int lock_fd;
30 const char *cache_name; 29 const char *cache_name;
@@ -187,7 +186,7 @@ static int fill_slot(struct cache_slot *slot)
187 return errno; 186 return errno;
188 187
189 /* Generate cache content */ 188 /* Generate cache content */
190 slot->fn(slot->cbdata); 189 slot->fn();
191 190
192 /* Restore stdout */ 191 /* Restore stdout */
193 if (dup2(tmp, STDOUT_FILENO) == -1) 192 if (dup2(tmp, STDOUT_FILENO) == -1)
@@ -277,7 +276,7 @@ static int process_slot(struct cache_slot *slot)
277 if ((err = lock_slot(slot)) != 0) { 276 if ((err = lock_slot(slot)) != 0) {
278 cache_log("[cgit] Unable to lock slot %s: %s (%d)\n", 277 cache_log("[cgit] Unable to lock slot %s: %s (%d)\n",
279 slot->lock_name, strerror(err), err); 278 slot->lock_name, strerror(err), err);
280 slot->fn(slot->cbdata); 279 slot->fn();
281 return 0; 280 return 0;
282 } 281 }
283 282
@@ -286,7 +285,7 @@ static int process_slot(struct cache_slot *slot)
286 slot->lock_name, strerror(err), err); 285 slot->lock_name, strerror(err), err);
287 unlock_slot(slot, 0); 286 unlock_slot(slot, 0);
288 close_lock(slot); 287 close_lock(slot);
289 slot->fn(slot->cbdata); 288 slot->fn();
290 return 0; 289 return 0;
291 } 290 }
292 // We've got a valid cache slot in the lock file, which 291 // We've got a valid cache slot in the lock file, which
@@ -310,7 +309,7 @@ static int process_slot(struct cache_slot *slot)
310 309
311/* Print cached content to stdout, generate the content if necessary. */ 310/* Print cached content to stdout, generate the content if necessary. */
312int cache_process(int size, const char *path, const char *key, int ttl, 311int cache_process(int size, const char *path, const char *key, int ttl,
313 cache_fill_fn fn, void *cbdata) 312 cache_fill_fn fn)
314{ 313{
315 unsigned long hash; 314 unsigned long hash;
316 int i; 315 int i;
@@ -321,14 +320,14 @@ int cache_process(int size, const char *path, const char *key, int ttl,
321 320
322 /* If the cache is disabled, just generate the content */ 321 /* If the cache is disabled, just generate the content */
323 if (size <= 0) { 322 if (size <= 0) {
324 fn(cbdata); 323 fn();
325 return 0; 324 return 0;
326 } 325 }
327 326
328 /* Verify input, calculate filenames */ 327 /* Verify input, calculate filenames */
329 if (!path) { 328 if (!path) {
330 cache_log("[cgit] Cache path not specified, caching is disabled\n"); 329 cache_log("[cgit] Cache path not specified, caching is disabled\n");
331 fn(cbdata); 330 fn();
332 return 0; 331 return 0;
333 } 332 }
334 if (!key) 333 if (!key)
@@ -343,7 +342,6 @@ int cache_process(int size, const char *path, const char *key, int ttl,
343 strbuf_addbuf(&lockname, &filename); 342 strbuf_addbuf(&lockname, &filename);
344 strbuf_addstr(&lockname, ".lock"); 343 strbuf_addstr(&lockname, ".lock");
345 slot.fn = fn; 344 slot.fn = fn;
346 slot.cbdata = cbdata;
347 slot.ttl = ttl; 345 slot.ttl = ttl;
348 slot.cache_name = filename.buf; 346 slot.cache_name = filename.buf;
349 slot.lock_name = lockname.buf; 347 slot.lock_name = lockname.buf;