mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-25 15:10:48 +01:00
Add handle support to consensus_cache_entry_t
This will allow us to have weak references to cache entries.
This commit is contained in:
parent
5726fec9c2
commit
82bb8afb60
2 changed files with 8 additions and 0 deletions
|
@ -16,6 +16,7 @@
|
||||||
*/
|
*/
|
||||||
struct consensus_cache_entry_t {
|
struct consensus_cache_entry_t {
|
||||||
uint32_t magic; /**< Must be set to CCE_MAGIC */
|
uint32_t magic; /**< Must be set to CCE_MAGIC */
|
||||||
|
HANDLE_ENTRY(consensus_cache_entry, consensus_cache_entry_t);
|
||||||
int32_t refcnt; /**< Reference count. */
|
int32_t refcnt; /**< Reference count. */
|
||||||
unsigned can_remove : 1; /**< If true, we want to delete this file. */
|
unsigned can_remove : 1; /**< If true, we want to delete this file. */
|
||||||
/** If true, we intend to unmap this file as soon as we're done with it. */
|
/** If true, we intend to unmap this file as soon as we're done with it. */
|
||||||
|
@ -305,6 +306,7 @@ consensus_cache_entry_decref(consensus_cache_entry_t *ent)
|
||||||
}
|
}
|
||||||
tor_free(ent->fname);
|
tor_free(ent->fname);
|
||||||
config_free_lines(ent->labels);
|
config_free_lines(ent->labels);
|
||||||
|
consensus_cache_entry_handles_clear(ent);
|
||||||
memwipe(ent, 0, sizeof(consensus_cache_entry_t));
|
memwipe(ent, 0, sizeof(consensus_cache_entry_t));
|
||||||
tor_free(ent);
|
tor_free(ent);
|
||||||
}
|
}
|
||||||
|
@ -490,6 +492,8 @@ consensus_cache_entry_unmap(consensus_cache_entry_t *ent)
|
||||||
ent->unused_since = TIME_MAX;
|
ent->unused_since = TIME_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HANDLE_IMPL(consensus_cache_entry, consensus_cache_entry_t, )
|
||||||
|
|
||||||
#ifdef TOR_UNIT_TESTS
|
#ifdef TOR_UNIT_TESTS
|
||||||
/**
|
/**
|
||||||
* Testing only: Return true iff <b>ent</b> is mapped into memory.
|
* Testing only: Return true iff <b>ent</b> is mapped into memory.
|
||||||
|
|
|
@ -4,9 +4,13 @@
|
||||||
#ifndef TOR_CONSCACHE_H
|
#ifndef TOR_CONSCACHE_H
|
||||||
#define TOR_CONSCACHE_H
|
#define TOR_CONSCACHE_H
|
||||||
|
|
||||||
|
#include "handles.h"
|
||||||
|
|
||||||
typedef struct consensus_cache_entry_t consensus_cache_entry_t;
|
typedef struct consensus_cache_entry_t consensus_cache_entry_t;
|
||||||
typedef struct consensus_cache_t consensus_cache_t;
|
typedef struct consensus_cache_t consensus_cache_t;
|
||||||
|
|
||||||
|
HANDLE_DECL(consensus_cache_entry, consensus_cache_entry_t, )
|
||||||
|
|
||||||
consensus_cache_t *consensus_cache_open(const char *subdir, int max_entries);
|
consensus_cache_t *consensus_cache_open(const char *subdir, int max_entries);
|
||||||
void consensus_cache_free(consensus_cache_t *cache);
|
void consensus_cache_free(consensus_cache_t *cache);
|
||||||
void consensus_cache_unmap_lazy(consensus_cache_t *cache, time_t cutoff);
|
void consensus_cache_unmap_lazy(consensus_cache_t *cache, time_t cutoff);
|
||||||
|
|
Loading…
Add table
Reference in a new issue