safe_close(f->fd);
free(f->path);
- ordered_hashmap_free_free(f->chain_cache);
+ ordered_hashmap_free(f->chain_cache);
#if HAVE_COMPRESSION
free(f->compress_buffer);
} ChainCacheItem;
static void chain_cache_put(
- OrderedHashmap *h,
+ JournalFile *f,
ChainCacheItem *ci,
uint64_t first,
uint64_t array,
uint64_t total,
uint64_t last_index) {
- assert(h);
+ assert(f);
if (!ci) {
/* If the chain item to cache for this chain is the
if (array == first)
return;
- if (ordered_hashmap_size(h) >= CHAIN_CACHE_MAX) {
- ci = ordered_hashmap_steal_first(h);
+ if (ordered_hashmap_size(f->chain_cache) >= CHAIN_CACHE_MAX) {
+ ci = ordered_hashmap_steal_first(f->chain_cache);
assert(ci);
} else {
ci = new(ChainCacheItem, 1);
ci->first = first;
- if (ordered_hashmap_put(h, &ci->first, ci) < 0) {
+ if (ordered_hashmap_ensure_put(&f->chain_cache, &uint64_hash_ops_value_free, &ci->first, ci) < 0) {
free(ci);
return;
}
r = journal_file_move_to_object(f, OBJECT_ENTRY, p, ret_object);
if (r >= 0) {
/* Let's cache this item for the next invocation */
- chain_cache_put(f->chain_cache, ci, first, a, journal_file_entry_array_item(f, o, 0), t, i);
+ chain_cache_put(f, ci, first, a, journal_file_entry_array_item(f, o, 0), t, i);
if (ret_offset)
*ret_offset = p;
return -EBADMSG;
/* Let's cache this item for the next invocation */
- chain_cache_put(f->chain_cache, ci, first, a, p, t, i);
+ chain_cache_put(f, ci, first, a, p, t, i);
p = journal_file_entry_array_item(f, array, i);
if (p == 0)
}
}
- f->chain_cache = ordered_hashmap_new(&uint64_hash_ops);
- if (!f->chain_cache) {
- r = -ENOMEM;
- goto fail;
- }
-
if (f->fd < 0) {
/* We pass O_NONBLOCK here, so that in case somebody pointed us to some character device node or FIFO
* or so, we likely fail quickly than block for long. For regular files O_NONBLOCK has no effect, hence