diff options
author | Lukas Fleischer | 2014-01-15 21:53:15 +0100 |
---|---|---|
committer | Jason A. Donenfeld | 2014-01-17 00:44:54 +0100 |
commit | f60ffa143cca61e9729ac71033e1a556cf422871 (patch) | |
tree | ff9122fef2779ddea8e37806cc66dc67b63df99f /cache.c | |
parent | a431326e8fab8153905fbde036dd3c9fb4cc8eaa (diff) | |
download | cgit-f60ffa143cca61e9729ac71033e1a556cf422871.tar.gz cgit-f60ffa143cca61e9729ac71033e1a556cf422871.tar.bz2 cgit-f60ffa143cca61e9729ac71033e1a556cf422871.zip |
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.c | 14 |
1 files changed, 6 insertions, 8 deletions
@@ -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. */ |
312 | int cache_process(int size, const char *path, const char *key, int ttl, | 311 | int 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; |