diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c index cd338f8b353..c4872e59ee2 100644 --- a/src/util/disk_cache.c +++ b/src/util/disk_cache.c @@ -426,6 +426,10 @@ destroy_put_job_nocopy(void *job, void *gdata, int thread_index) destroy_put_job(job, gdata, thread_index); } +static void +blob_put_compressed(struct disk_cache *cache, const cache_key key, + const void *data, size_t size); + static void cache_put(void *job, void *gdata, int thread_index) { @@ -435,7 +439,9 @@ cache_put(void *job, void *gdata, int thread_index) char *filename = NULL; struct disk_cache_put_job *dc_job = (struct disk_cache_put_job *) job; - if (dc_job->cache->type == DISK_CACHE_SINGLE_FILE) { + if (dc_job->cache->blob_put_cb) { + blob_put_compressed(dc_job->cache, dc_job->key, dc_job->data, dc_job->size); + } else if (dc_job->cache->type == DISK_CACHE_SINGLE_FILE) { disk_cache_write_item_to_disk_foz(dc_job); } else if (dc_job->cache->type == DISK_CACHE_DATABASE) { disk_cache_db_write_item_to_disk(dc_job); @@ -546,11 +552,6 @@ disk_cache_put(struct disk_cache *cache, const cache_key key, const void *data, size_t size, struct cache_item_metadata *cache_item_metadata) { - if (cache->blob_put_cb) { - blob_put_compressed(cache, key, data, size); - return; - } - if (!util_queue_is_initialized(&cache->cache_queue)) return; @@ -569,12 +570,6 @@ disk_cache_put_nocopy(struct disk_cache *cache, const cache_key key, void *data, size_t size, struct cache_item_metadata *cache_item_metadata) { - if (cache->blob_put_cb) { - blob_put_compressed(cache, key, data, size); - free(data); - return; - } - if (!util_queue_is_initialized(&cache->cache_queue)) { free(data); return; @@ -691,6 +686,7 @@ disk_cache_set_callbacks(struct disk_cache *cache, disk_cache_put_cb put, { cache->blob_put_cb = put; cache->blob_get_cb = get; + disk_cache_init_queue(cache); } #endif /* ENABLE_SHADER_CACHE */