Tor
0.4.7.0-alpha-dev
|
Header for conscache.c. More...
#include "lib/container/handles.h"
Go to the source code of this file.
Macros | |
#define | consensus_cache_entry_handle_free(h) |
#define | consensus_cache_free(cache) FREE_AND_NULL(consensus_cache_t, consensus_cache_free_, (cache)) |
Header for conscache.c.
Definition in file conscache.h.
#define consensus_cache_entry_handle_free | ( | h | ) |
Definition at line 20 of file conscache.h.
void consensus_cache_delete_pending | ( | consensus_cache_t * | cache, |
int | force | ||
) |
Delete every element of cache has been marked with consensus_cache_entry_mark_for_removal. If force is false, retain those entries which are in use by something other than the cache.
Definition at line 509 of file conscache.c.
Referenced by consdiffmgr_ensure_space_for_files(), and consensus_cache_clear().
void consensus_cache_entry_decref | ( | consensus_cache_entry_t * | ent | ) |
Release a reference held to ent.
If it was the last reference, ent will be freed. Therefore, you must not use ent after calling this function.
Definition at line 370 of file conscache.c.
Referenced by consensus_cache_clear(), and spooled_resource_free_().
int consensus_cache_entry_get_body | ( | const consensus_cache_entry_t * | ent, |
const uint8_t ** | body_out, | ||
size_t * | sz_out | ||
) |
Try to read the body of ent into memory if it isn't already loaded. On success, set *body_out to the body, *sz_out to its size, and return 0. On failure return -1.
The resulting body pointer will only be valid for as long as you hold a reference to ent.
Definition at line 437 of file conscache.c.
Referenced by consensus_diff_worker_threadfn(), and uncompress_or_set_ptr().
const struct config_line_t* consensus_cache_entry_get_labels | ( | const consensus_cache_entry_t * | ent | ) |
Return a pointer to the labels in ent.
This pointer is only guaranteed to be valid for as long as you hold a reference to ent.
Definition at line 346 of file conscache.c.
const char* consensus_cache_entry_get_value | ( | const consensus_cache_entry_t * | ent, |
const char * | key | ||
) |
If ent has a label with the given key, return its value. Otherwise return NULL.
The return value is only guaranteed to be valid for as long as you hold a reference to ent.
Definition at line 329 of file conscache.c.
Referenced by cdm_entry_get_sha3_value(), compare_by_staleness_(), compare_by_valid_after_(), consensus_cache_entry_get_fresh_until(), consensus_cache_entry_get_valid_after(), consensus_cache_entry_get_valid_until(), consensus_cache_entry_get_voter_id_digests(), consensus_cache_find_all(), consensus_diff_worker_replyfn(), and uncompress_or_set_ptr().
void consensus_cache_entry_incref | ( | consensus_cache_entry_t * | ent | ) |
Increase the reference count of ent.
Definition at line 355 of file conscache.c.
Referenced by consensus_diff_queue_diff_work().
void consensus_cache_entry_mark_for_aggressive_release | ( | consensus_cache_entry_t * | ent | ) |
Mark ent as the kind of entry that we don't need to keep mmap'd for any longer than we're actually using it.
Definition at line 423 of file conscache.c.
void consensus_cache_entry_mark_for_removal | ( | consensus_cache_entry_t * | ent | ) |
Mark ent for deletion from the cache. Deletion will not occur until the cache is the only place that holds a reference to ent.
Definition at line 413 of file conscache.c.
Referenced by consdiffmgr_ensure_space_for_files().
void consensus_cache_filter_list | ( | smartlist_t * | lst, |
const char * | key, | ||
const char * | value | ||
) |
Given a list of consensus_cache_entry_t, remove all those entries that do not have key=value in their labels.
Does not adjust reference counts.
Definition at line 305 of file conscache.c.
void consensus_cache_find_all | ( | smartlist_t * | out, |
consensus_cache_t * | cache, | ||
const char * | key, | ||
const char * | value | ||
) |
Given a cache, add every entry to out for which key=value. If key is NULL, add every entry.
Do not add any entry that has been marked for removal.
Does not adjust reference counts.
Definition at line 277 of file conscache.c.
Referenced by consdiffmgr_consensus_load(), consdiffmgr_diffs_load(), consdiffmgr_ensure_space_for_files(), consdiffmgr_rescan_flavor_(), consdiffmgr_set_cache_flags(), consdiffmgr_validate(), and consensus_cache_find_first().
consensus_cache_entry_t* consensus_cache_find_first | ( | consensus_cache_t * | cache, |
const char * | key, | ||
const char * | value | ||
) |
Given a cache, return some entry for which key=value. Return NULL if no such entry exists.
Does not adjust reference counts.
Definition at line 255 of file conscache.c.
void consensus_cache_free_ | ( | consensus_cache_t * | cache | ) |
Drop all storage held by cache.
Definition at line 195 of file conscache.c.
int consensus_cache_get_n_filenames_available | ( | consensus_cache_t * | cache | ) |
Return the number of currently unused filenames available in this cache.
Definition at line 489 of file conscache.c.
Referenced by consdiffmgr_ensure_space_for_files().
int consensus_cache_may_overallocate | ( | consensus_cache_t * | cache | ) |
Return true if it's okay to put more entries in this cache than its official file limit.
(We need this method on Windows, where we can't unlink files that are still in use, and therefore might need to temporarily exceed the file limit until the no-longer-wanted files are deletable.)
Definition at line 125 of file conscache.c.
consensus_cache_t* consensus_cache_open | ( | const char * | subdir, |
int | max_entries | ||
) |
Helper: Open a consensus cache in subdirectory subdir of the data directory, to hold up to max_entries of data.
Definition at line 85 of file conscache.c.
Referenced by cdm_cache_init().
int consensus_cache_register_with_sandbox | ( | consensus_cache_t * | cache, |
struct sandbox_cfg_elem_t ** | cfg | ||
) |
Tell the sandbox (if any) configured by cfg to allow the operations that cache will need.
Definition at line 149 of file conscache.c.
Referenced by consdiffmgr_register_with_sandbox().
void consensus_cache_unmap_lazy | ( | consensus_cache_t * | cache, |
time_t | cutoff | ||
) |
Unmap every mmap'd element of cache that has been unused since cutoff.
Definition at line 465 of file conscache.c.