diff options
-rw-r--r-- | cache.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -316,6 +316,7 @@ int cache_process(int size, const char *path, const char *key, int ttl, | |||
316 | struct strbuf filename = STRBUF_INIT; | 316 | struct strbuf filename = STRBUF_INIT; |
317 | struct strbuf lockname = STRBUF_INIT; | 317 | struct strbuf lockname = STRBUF_INIT; |
318 | struct cache_slot slot; | 318 | struct cache_slot slot; |
319 | int result; | ||
319 | 320 | ||
320 | /* If the cache is disabled, just generate the content */ | 321 | /* If the cache is disabled, just generate the content */ |
321 | if (size <= 0) { | 322 | if (size <= 0) { |
@@ -343,11 +344,15 @@ int cache_process(int size, const char *path, const char *key, int ttl, | |||
343 | slot.fn = fn; | 344 | slot.fn = fn; |
344 | slot.cbdata = cbdata; | 345 | slot.cbdata = cbdata; |
345 | slot.ttl = ttl; | 346 | slot.ttl = ttl; |
346 | slot.cache_name = strbuf_detach(&filename, NULL); | 347 | slot.cache_name = filename.buf; |
347 | slot.lock_name = strbuf_detach(&lockname, NULL); | 348 | slot.lock_name = lockname.buf; |
348 | slot.key = key; | 349 | slot.key = key; |
349 | slot.keylen = strlen(key); | 350 | slot.keylen = strlen(key); |
350 | return process_slot(&slot); | 351 | result = process_slot(&slot); |
352 | |||
353 | strbuf_release(&filename); | ||
354 | strbuf_release(&lockname); | ||
355 | return result; | ||
351 | } | 356 | } |
352 | 357 | ||
353 | /* Return a strftime formatted date/time | 358 | /* Return a strftime formatted date/time |
@@ -393,6 +398,7 @@ int cache_ls(const char *path) | |||
393 | continue; | 398 | continue; |
394 | strbuf_setlen(&fullname, prefixlen); | 399 | strbuf_setlen(&fullname, prefixlen); |
395 | strbuf_addstr(&fullname, ent->d_name); | 400 | strbuf_addstr(&fullname, ent->d_name); |
401 | slot.cache_name = fullname.buf; | ||
396 | if ((err = open_slot(&slot)) != 0) { | 402 | if ((err = open_slot(&slot)) != 0) { |
397 | cache_log("[cgit] unable to open path %s: %s (%d)\n", | 403 | cache_log("[cgit] unable to open path %s: %s (%d)\n", |
398 | fullname.buf, strerror(err), err); | 404 | fullname.buf, strerror(err), err); |
@@ -406,8 +412,8 @@ int cache_ls(const char *path) | |||
406 | slot.buf); | 412 | slot.buf); |
407 | close_slot(&slot); | 413 | close_slot(&slot); |
408 | } | 414 | } |
409 | slot.cache_name = strbuf_detach(&fullname, NULL); | ||
410 | closedir(dir); | 415 | closedir(dir); |
416 | strbuf_release(&fullname); | ||
411 | return 0; | 417 | return 0; |
412 | } | 418 | } |
413 | 419 | ||