blob: b169d20f779aaa21ed5c3bd8e4e21c62500a0c90 [file] [log] [blame]
Lars Hjemli7640d902006-12-10 22:41:14 +01001/* cache.c: cache management
2 *
Lukas Fleischerf7f26f82014-01-08 15:10:49 +01003 * Copyright (C) 2006-2014 cgit Development Team <cgit@lists.zx2c4.com>
Lars Hjemli7640d902006-12-10 22:41:14 +01004 *
5 * Licensed under GNU General Public License v2
6 * (see COPYING for full license text)
Lars Hjemli939d32f2008-04-28 11:32:42 +02007 *
8 *
9 * The cache is just a directory structure where each file is a cache slot,
10 * and each filename is based on the hash of some key (e.g. the cgit url).
11 * Each file contains the full key followed by the cached content for that
12 * key.
13 *
Lars Hjemli7640d902006-12-10 22:41:14 +010014 */
15
Lars Hjemli25105d72006-12-10 22:31:36 +010016#include "cgit.h"
Lars Hjemliee4056b2008-03-27 09:22:13 +010017#include "cache.h"
John Keepingf32a2da2013-05-18 18:46:39 +010018#include "html.h"
John Keeping43620cf2015-08-13 12:14:17 +010019#ifdef HAVE_LINUX_SENDFILE
20#include <sys/sendfile.h>
21#endif
Lars Hjemli25105d72006-12-10 22:31:36 +010022
Lars Hjemli939d32f2008-04-28 11:32:42 +020023#define CACHE_BUFSIZE (1024 * 4)
Lars Hjemli25105d72006-12-10 22:31:36 +010024
Lars Hjemli939d32f2008-04-28 11:32:42 +020025struct cache_slot {
26 const char *key;
27 int keylen;
28 int ttl;
29 cache_fill_fn fn;
Lars Hjemli939d32f2008-04-28 11:32:42 +020030 int cache_fd;
31 int lock_fd;
32 const char *cache_name;
33 const char *lock_name;
34 int match;
35 struct stat cache_st;
Lars Hjemli939d32f2008-04-28 11:32:42 +020036 int bufsize;
37 char buf[CACHE_BUFSIZE];
38};
39
40/* Open an existing cache slot and fill the cache buffer with
41 * (part of) the content of the cache file. Return 0 on success
42 * and errno otherwise.
43 */
44static int open_slot(struct cache_slot *slot)
Lars Hjemli2c2047f2007-01-12 00:24:35 +010045{
Lars Hjemli939d32f2008-04-28 11:32:42 +020046 char *bufz;
47 int bufkeylen = -1;
Lars Hjemli2c2047f2007-01-12 00:24:35 +010048
Lars Hjemli939d32f2008-04-28 11:32:42 +020049 slot->cache_fd = open(slot->cache_name, O_RDONLY);
50 if (slot->cache_fd == -1)
51 return errno;
Lars Hjemli72fa5c62007-05-18 03:54:15 +020052
Lars Hjemli939d32f2008-04-28 11:32:42 +020053 if (fstat(slot->cache_fd, &slot->cache_st))
54 return errno;
55
Lars Hjemlicdc6b2f2008-05-18 23:26:05 +020056 slot->bufsize = xread(slot->cache_fd, slot->buf, sizeof(slot->buf));
Lars Hjemli6102bcf2008-05-18 23:10:05 +020057 if (slot->bufsize < 0)
Lars Hjemli939d32f2008-04-28 11:32:42 +020058 return errno;
59
60 bufz = memchr(slot->buf, 0, slot->bufsize);
61 if (bufz)
62 bufkeylen = bufz - slot->buf;
63
64 slot->match = bufkeylen == slot->keylen &&
65 !memcmp(slot->key, slot->buf, bufkeylen + 1);
66
67 return 0;
Lars Hjemli2c2047f2007-01-12 00:24:35 +010068}
69
Lars Hjemli939d32f2008-04-28 11:32:42 +020070/* Close the active cache slot */
Lars Hjemlid4028112008-05-18 23:16:50 +020071static int close_slot(struct cache_slot *slot)
Lars Hjemlif5069d82006-12-11 09:57:58 +010072{
Lars Hjemlid4028112008-05-18 23:16:50 +020073 int err = 0;
Lars Hjemli939d32f2008-04-28 11:32:42 +020074 if (slot->cache_fd > 0) {
Lars Hjemlid4028112008-05-18 23:16:50 +020075 if (close(slot->cache_fd))
76 err = errno;
77 else
78 slot->cache_fd = -1;
Lars Hjemli25105d72006-12-10 22:31:36 +010079 }
Lars Hjemlid4028112008-05-18 23:16:50 +020080 return err;
Lars Hjemli25105d72006-12-10 22:31:36 +010081}
82
Lars Hjemli939d32f2008-04-28 11:32:42 +020083/* Print the content of the active cache slot (but skip the key). */
84static int print_slot(struct cache_slot *slot)
Lars Hjemli25105d72006-12-10 22:31:36 +010085{
Sebastian Andrzej Siewiord3581b52014-01-18 21:24:58 +010086#ifdef HAVE_LINUX_SENDFILE
87 off_t start_off;
88 int ret;
89
90 start_off = slot->keylen + 1;
91
92 do {
93 ret = sendfile(STDOUT_FILENO, slot->cache_fd, &start_off,
94 slot->cache_st.st_size - start_off);
95 if (ret < 0) {
96 if (errno == EAGAIN || errno == EINTR)
97 continue;
98 return errno;
99 }
100 return 0;
101 } while (1);
102#else
Lars Hjemlidd7c1722008-05-20 17:56:47 +0200103 ssize_t i, j;
Lars Hjemli25105d72006-12-10 22:31:36 +0100104
Lars Hjemli939d32f2008-04-28 11:32:42 +0200105 i = lseek(slot->cache_fd, slot->keylen + 1, SEEK_SET);
106 if (i != slot->keylen + 1)
107 return errno;
108
Lars Hjemlidd7c1722008-05-20 17:56:47 +0200109 do {
110 i = j = xread(slot->cache_fd, slot->buf, sizeof(slot->buf));
111 if (i > 0)
112 j = xwrite(STDOUT_FILENO, slot->buf, i);
113 } while (i > 0 && j == i);
Lars Hjemli939d32f2008-04-28 11:32:42 +0200114
Lars Hjemlidd7c1722008-05-20 17:56:47 +0200115 if (i < 0 || j != i)
Lars Hjemli939d32f2008-04-28 11:32:42 +0200116 return errno;
117 else
Lars Hjemli7c849d92006-12-16 13:55:58 +0100118 return 0;
Sebastian Andrzej Siewiord3581b52014-01-18 21:24:58 +0100119#endif
Lars Hjemli25105d72006-12-10 22:31:36 +0100120}
121
Lars Hjemli939d32f2008-04-28 11:32:42 +0200122/* Check if the slot has expired */
123static int is_expired(struct cache_slot *slot)
124{
125 if (slot->ttl < 0)
126 return 0;
127 else
Lukas Fleischer53bc7472013-03-03 16:04:29 +0100128 return slot->cache_st.st_mtime + slot->ttl * 60 < time(NULL);
Lars Hjemli939d32f2008-04-28 11:32:42 +0200129}
130
131/* Check if the slot has been modified since we opened it.
132 * NB: If stat() fails, we pretend the file is modified.
133 */
134static int is_modified(struct cache_slot *slot)
Lars Hjemli318d1062006-12-11 12:10:12 +0100135{
136 struct stat st;
137
Lars Hjemli939d32f2008-04-28 11:32:42 +0200138 if (stat(slot->cache_name, &st))
139 return 1;
140 return (st.st_ino != slot->cache_st.st_ino ||
141 st.st_mtime != slot->cache_st.st_mtime ||
142 st.st_size != slot->cache_st.st_size);
143}
144
145/* Close an open lockfile */
Lars Hjemlid4028112008-05-18 23:16:50 +0200146static int close_lock(struct cache_slot *slot)
Lars Hjemli939d32f2008-04-28 11:32:42 +0200147{
Lars Hjemlid4028112008-05-18 23:16:50 +0200148 int err = 0;
Lars Hjemli939d32f2008-04-28 11:32:42 +0200149 if (slot->lock_fd > 0) {
Lars Hjemlid4028112008-05-18 23:16:50 +0200150 if (close(slot->lock_fd))
151 err = errno;
152 else
153 slot->lock_fd = -1;
Lars Hjemli939d32f2008-04-28 11:32:42 +0200154 }
Lars Hjemlid4028112008-05-18 23:16:50 +0200155 return err;
Lars Hjemli939d32f2008-04-28 11:32:42 +0200156}
157
158/* Create a lockfile used to store the generated content for a cache
159 * slot, and write the slot key + \0 into it.
160 * Returns 0 on success and errno otherwise.
161 */
162static int lock_slot(struct cache_slot *slot)
163{
John Keepingdb9a70b2015-03-03 19:22:31 +0000164 struct flock lock = {
165 .l_type = F_WRLCK,
166 .l_whence = SEEK_SET,
167 .l_start = 0,
168 .l_len = 0,
169 };
170
171 slot->lock_fd = open(slot->lock_name, O_RDWR | O_CREAT,
Lukas Fleischer53bc7472013-03-03 16:04:29 +0100172 S_IRUSR | S_IWUSR);
Lars Hjemli939d32f2008-04-28 11:32:42 +0200173 if (slot->lock_fd == -1)
174 return errno;
John Keepingdb9a70b2015-03-03 19:22:31 +0000175 if (fcntl(slot->lock_fd, F_SETLK, &lock) < 0) {
176 int saved_errno = errno;
177 close(slot->lock_fd);
178 slot->lock_fd = -1;
179 return saved_errno;
180 }
Lars Hjemlicdc6b2f2008-05-18 23:26:05 +0200181 if (xwrite(slot->lock_fd, slot->key, slot->keylen + 1) < 0)
Lars Hjemlid4028112008-05-18 23:16:50 +0200182 return errno;
Lars Hjemli939d32f2008-04-28 11:32:42 +0200183 return 0;
184}
185
186/* Release the current lockfile. If `replace_old_slot` is set the
187 * lockfile replaces the old cache slot, otherwise the lockfile is
188 * just deleted.
189 */
190static int unlock_slot(struct cache_slot *slot, int replace_old_slot)
191{
192 int err;
193
194 if (replace_old_slot)
195 err = rename(slot->lock_name, slot->cache_name);
Lars Hjemli318d1062006-12-11 12:10:12 +0100196 else
Lars Hjemli939d32f2008-04-28 11:32:42 +0200197 err = unlink(slot->lock_name);
Lars Hjemlid4028112008-05-18 23:16:50 +0200198
199 if (err)
200 return errno;
201
202 return 0;
Lars Hjemli318d1062006-12-11 12:10:12 +0100203}
204
Lars Hjemli939d32f2008-04-28 11:32:42 +0200205/* Generate the content for the current cache slot by redirecting
206 * stdout to the lock-fd and invoking the callback function
207 */
208static int fill_slot(struct cache_slot *slot)
Lars Hjemli25105d72006-12-10 22:31:36 +0100209{
Lars Hjemli939d32f2008-04-28 11:32:42 +0200210 int tmp;
Lars Hjemli25105d72006-12-10 22:31:36 +0100211
Lars Hjemli939d32f2008-04-28 11:32:42 +0200212 /* Preserve stdout */
213 tmp = dup(STDOUT_FILENO);
214 if (tmp == -1)
215 return errno;
Lars Hjemli318d1062006-12-11 12:10:12 +0100216
Lars Hjemli939d32f2008-04-28 11:32:42 +0200217 /* Redirect stdout to lockfile */
Christian Hesse76dc7a32015-10-10 16:56:28 +0200218 if (dup2(slot->lock_fd, STDOUT_FILENO) == -1) {
219 close(tmp);
Lars Hjemli939d32f2008-04-28 11:32:42 +0200220 return errno;
Christian Hesse76dc7a32015-10-10 16:56:28 +0200221 }
Lars Hjemli318d1062006-12-11 12:10:12 +0100222
Lars Hjemli939d32f2008-04-28 11:32:42 +0200223 /* Generate cache content */
Lukas Fleischerf60ffa12014-01-15 21:53:15 +0100224 slot->fn();
Lars Hjemli318d1062006-12-11 12:10:12 +0100225
Sebastian Andrzej Siewiord3581b52014-01-18 21:24:58 +0100226 /* update stat info */
Christian Hesse76dc7a32015-10-10 16:56:28 +0200227 if (fstat(slot->lock_fd, &slot->cache_st)) {
228 close(tmp);
Sebastian Andrzej Siewiord3581b52014-01-18 21:24:58 +0100229 return errno;
Christian Hesse76dc7a32015-10-10 16:56:28 +0200230 }
Sebastian Andrzej Siewiord3581b52014-01-18 21:24:58 +0100231
Lars Hjemli939d32f2008-04-28 11:32:42 +0200232 /* Restore stdout */
Christian Hesse76dc7a32015-10-10 16:56:28 +0200233 if (dup2(tmp, STDOUT_FILENO) == -1) {
234 close(tmp);
Lars Hjemli939d32f2008-04-28 11:32:42 +0200235 return errno;
Christian Hesse76dc7a32015-10-10 16:56:28 +0200236 }
Lars Hjemli318d1062006-12-11 12:10:12 +0100237
Lars Hjemli939d32f2008-04-28 11:32:42 +0200238 /* Close the temporary filedescriptor */
Lars Hjemlid4028112008-05-18 23:16:50 +0200239 if (close(tmp))
240 return errno;
241
Lars Hjemli939d32f2008-04-28 11:32:42 +0200242 return 0;
Lars Hjemli25105d72006-12-10 22:31:36 +0100243}
244
Lars Hjemli939d32f2008-04-28 11:32:42 +0200245/* Crude implementation of 32-bit FNV-1 hash algorithm,
246 * see http://www.isthe.com/chongo/tech/comp/fnv/ for details
247 * about the magic numbers.
248 */
249#define FNV_OFFSET 0x811c9dc5
250#define FNV_PRIME 0x01000193
251
252unsigned long hash_str(const char *str)
Lars Hjemli25105d72006-12-10 22:31:36 +0100253{
Lars Hjemli939d32f2008-04-28 11:32:42 +0200254 unsigned long h = FNV_OFFSET;
255 unsigned char *s = (unsigned char *)str;
256
257 if (!s)
258 return h;
259
Jason A. Donenfeldbdae1d82013-03-03 23:21:33 -0500260 while (*s) {
Lars Hjemli939d32f2008-04-28 11:32:42 +0200261 h *= FNV_PRIME;
262 h ^= *s++;
263 }
264 return h;
Lars Hjemli25105d72006-12-10 22:31:36 +0100265}
266
Lars Hjemli939d32f2008-04-28 11:32:42 +0200267static int process_slot(struct cache_slot *slot)
Lars Hjemlifbaf1172006-12-11 22:53:50 +0100268{
Lars Hjemli939d32f2008-04-28 11:32:42 +0200269 int err;
Lars Hjemlifbaf1172006-12-11 22:53:50 +0100270
Lars Hjemli939d32f2008-04-28 11:32:42 +0200271 err = open_slot(slot);
272 if (!err && slot->match) {
273 if (is_expired(slot)) {
274 if (!lock_slot(slot)) {
275 /* If the cachefile has been replaced between
276 * `open_slot` and `lock_slot`, we'll just
277 * serve the stale content from the original
278 * cachefile. This way we avoid pruning the
279 * newly generated slot. The same code-path
280 * is chosen if fill_slot() fails for some
281 * reason.
282 *
283 * TODO? check if the new slot contains the
284 * same key as the old one, since we would
285 * prefer to serve the newest content.
286 * This will require us to open yet another
287 * file-descriptor and read and compare the
288 * key from the new file, so for now we're
289 * lazy and just ignore the new file.
290 */
291 if (is_modified(slot) || fill_slot(slot)) {
292 unlock_slot(slot, 0);
293 close_lock(slot);
294 } else {
295 close_slot(slot);
296 unlock_slot(slot, 1);
297 slot->cache_fd = slot->lock_fd;
298 }
299 }
300 }
Lars Hjemliaf2e7562008-05-18 23:59:11 +0200301 if ((err = print_slot(slot)) != 0) {
302 cache_log("[cgit] error printing cache %s: %s (%d)\n",
303 slot->cache_name,
304 strerror(err),
305 err);
306 }
Lars Hjemli939d32f2008-04-28 11:32:42 +0200307 close_slot(slot);
Lars Hjemliaf2e7562008-05-18 23:59:11 +0200308 return err;
Lars Hjemli939d32f2008-04-28 11:32:42 +0200309 }
310
311 /* If the cache slot does not exist (or its key doesn't match the
312 * current key), lets try to create a new cache slot for this
313 * request. If this fails (for whatever reason), lets just generate
314 * the content without caching it and fool the caller to belive
315 * everything worked out (but print a warning on stdout).
316 */
317
318 close_slot(slot);
319 if ((err = lock_slot(slot)) != 0) {
320 cache_log("[cgit] Unable to lock slot %s: %s (%d)\n",
321 slot->lock_name, strerror(err), err);
Lukas Fleischerf60ffa12014-01-15 21:53:15 +0100322 slot->fn();
Lars Hjemli939d32f2008-04-28 11:32:42 +0200323 return 0;
324 }
325
326 if ((err = fill_slot(slot)) != 0) {
327 cache_log("[cgit] Unable to fill slot %s: %s (%d)\n",
328 slot->lock_name, strerror(err), err);
329 unlock_slot(slot, 0);
330 close_lock(slot);
Lukas Fleischerf60ffa12014-01-15 21:53:15 +0100331 slot->fn();
Lars Hjemli939d32f2008-04-28 11:32:42 +0200332 return 0;
333 }
334 // We've got a valid cache slot in the lock file, which
335 // is about to replace the old cache slot. But if we
336 // release the lockfile and then try to open the new cache
337 // slot, we might get a race condition with a concurrent
338 // writer for the same cache slot (with a different key).
339 // Lets avoid such a race by just printing the content of
340 // the lock file.
341 slot->cache_fd = slot->lock_fd;
342 unlock_slot(slot, 1);
Lars Hjemliaf2e7562008-05-18 23:59:11 +0200343 if ((err = print_slot(slot)) != 0) {
344 cache_log("[cgit] error printing cache %s: %s (%d)\n",
345 slot->cache_name,
346 strerror(err),
347 err);
348 }
Lars Hjemli939d32f2008-04-28 11:32:42 +0200349 close_slot(slot);
350 return err;
Lars Hjemli25105d72006-12-10 22:31:36 +0100351}
Lars Hjemli939d32f2008-04-28 11:32:42 +0200352
353/* Print cached content to stdout, generate the content if necessary. */
354int cache_process(int size, const char *path, const char *key, int ttl,
Lukas Fleischerf60ffa12014-01-15 21:53:15 +0100355 cache_fill_fn fn)
Lars Hjemli939d32f2008-04-28 11:32:42 +0200356{
357 unsigned long hash;
John Keepingfb3655d2013-04-06 10:28:57 +0100358 int i;
359 struct strbuf filename = STRBUF_INIT;
360 struct strbuf lockname = STRBUF_INIT;
Lars Hjemli939d32f2008-04-28 11:32:42 +0200361 struct cache_slot slot;
John Keepingf75900b2013-05-18 18:28:14 +0100362 int result;
Lars Hjemli939d32f2008-04-28 11:32:42 +0200363
364 /* If the cache is disabled, just generate the content */
Lukas Fleischer6ceba452014-02-20 20:59:22 +0100365 if (size <= 0 || ttl == 0) {
Lukas Fleischerf60ffa12014-01-15 21:53:15 +0100366 fn();
Lars Hjemli939d32f2008-04-28 11:32:42 +0200367 return 0;
368 }
369
370 /* Verify input, calculate filenames */
371 if (!path) {
372 cache_log("[cgit] Cache path not specified, caching is disabled\n");
Lukas Fleischerf60ffa12014-01-15 21:53:15 +0100373 fn();
Lars Hjemli939d32f2008-04-28 11:32:42 +0200374 return 0;
375 }
Lars Hjemli939d32f2008-04-28 11:32:42 +0200376 if (!key)
377 key = "";
378 hash = hash_str(key) % size;
John Keepingfb3655d2013-04-06 10:28:57 +0100379 strbuf_addstr(&filename, path);
380 strbuf_ensure_end(&filename, '/');
Jason A. Donenfeldbdae1d82013-03-03 23:21:33 -0500381 for (i = 0; i < 8; i++) {
John Keepingfb3655d2013-04-06 10:28:57 +0100382 strbuf_addf(&filename, "%x", (unsigned char)(hash & 0xf));
Lars Hjemli939d32f2008-04-28 11:32:42 +0200383 hash >>= 4;
384 }
John Keepingfb3655d2013-04-06 10:28:57 +0100385 strbuf_addbuf(&lockname, &filename);
386 strbuf_addstr(&lockname, ".lock");
Lars Hjemli939d32f2008-04-28 11:32:42 +0200387 slot.fn = fn;
Lars Hjemli939d32f2008-04-28 11:32:42 +0200388 slot.ttl = ttl;
John Keepingf75900b2013-05-18 18:28:14 +0100389 slot.cache_name = filename.buf;
390 slot.lock_name = lockname.buf;
Lars Hjemli939d32f2008-04-28 11:32:42 +0200391 slot.key = key;
392 slot.keylen = strlen(key);
John Keepingf75900b2013-05-18 18:28:14 +0100393 result = process_slot(&slot);
394
395 strbuf_release(&filename);
396 strbuf_release(&lockname);
397 return result;
Lars Hjemli939d32f2008-04-28 11:32:42 +0200398}
399
Lars Hjemli9000bbf2008-04-28 12:10:13 +0200400/* Return a strftime formatted date/time
401 * NB: the result from this function is to shared memory
402 */
Lukas Fleischerbafab422013-03-04 08:52:33 +0100403static char *sprintftime(const char *format, time_t time)
Lars Hjemli9000bbf2008-04-28 12:10:13 +0200404{
405 static char buf[64];
406 struct tm *tm;
407
408 if (!time)
409 return NULL;
410 tm = gmtime(&time);
411 strftime(buf, sizeof(buf)-1, format, tm);
412 return buf;
413}
414
415int cache_ls(const char *path)
416{
417 DIR *dir;
418 struct dirent *ent;
419 int err = 0;
John Keeping80d52072015-03-08 16:32:26 +0000420 struct cache_slot slot = { NULL };
John Keepingfb3655d2013-04-06 10:28:57 +0100421 struct strbuf fullname = STRBUF_INIT;
422 size_t prefixlen;
Lars Hjemli9000bbf2008-04-28 12:10:13 +0200423
424 if (!path) {
425 cache_log("[cgit] cache path not specified\n");
426 return -1;
427 }
Lars Hjemli9000bbf2008-04-28 12:10:13 +0200428 dir = opendir(path);
429 if (!dir) {
430 err = errno;
431 cache_log("[cgit] unable to open path %s: %s (%d)\n",
432 path, strerror(err), err);
433 return err;
434 }
John Keepingfb3655d2013-04-06 10:28:57 +0100435 strbuf_addstr(&fullname, path);
436 strbuf_ensure_end(&fullname, '/');
437 prefixlen = fullname.len;
Jason A. Donenfeldbdae1d82013-03-03 23:21:33 -0500438 while ((ent = readdir(dir)) != NULL) {
Lars Hjemli9000bbf2008-04-28 12:10:13 +0200439 if (strlen(ent->d_name) != 8)
440 continue;
John Keepingfb3655d2013-04-06 10:28:57 +0100441 strbuf_setlen(&fullname, prefixlen);
442 strbuf_addstr(&fullname, ent->d_name);
John Keepingf75900b2013-05-18 18:28:14 +0100443 slot.cache_name = fullname.buf;
Lars Hjemli9000bbf2008-04-28 12:10:13 +0200444 if ((err = open_slot(&slot)) != 0) {
445 cache_log("[cgit] unable to open path %s: %s (%d)\n",
John Keepingfb3655d2013-04-06 10:28:57 +0100446 fullname.buf, strerror(err), err);
Lars Hjemli9000bbf2008-04-28 12:10:13 +0200447 continue;
448 }
John Keepingf32a2da2013-05-18 18:46:39 +0100449 htmlf("%s %s %10"PRIuMAX" %s\n",
450 fullname.buf,
451 sprintftime("%Y-%m-%d %H:%M:%S",
452 slot.cache_st.st_mtime),
453 (uintmax_t)slot.cache_st.st_size,
454 slot.buf);
Lars Hjemli9000bbf2008-04-28 12:10:13 +0200455 close_slot(&slot);
456 }
457 closedir(dir);
John Keepingf75900b2013-05-18 18:28:14 +0100458 strbuf_release(&fullname);
Lars Hjemli9000bbf2008-04-28 12:10:13 +0200459 return 0;
460}
461
Lars Hjemli939d32f2008-04-28 11:32:42 +0200462/* Print a message to stdout */
463void cache_log(const char *format, ...)
464{
465 va_list args;
466 va_start(args, format);
467 vfprintf(stderr, format, args);
468 va_end(args);
469}
470