testbed cache implementation More...
Go to the source code of this file.
Data Structures | |
struct | CacheEntry |
Cache entry. More... | |
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "testbed-cache", __VA_ARGS__) |
Redefine LOG with a changed log component string. More... | |
Functions | |
static struct CacheEntry * | cache_lookup (unsigned int peer_id) |
Looks up in the cache and returns the entry. More... | |
static void | free_entry (struct CacheEntry *entry) |
Free the resources occupied by a cache entry. More... | |
static struct CacheEntry * | add_entry (unsigned int peer_id) |
Creates a new cache entry and then puts it into the cache's hashtable. More... | |
static int | cache_clear_iterator (void *cls, uint32_t key, void *value) |
Iterator over hash map entries. More... | |
void | GST_cache_clear () |
Clear cache. More... | |
void | GST_cache_init (unsigned int size) |
Initializes the cache. More... | |
const struct GNUNET_MessageHeader * | GST_cache_lookup_hello (const unsigned int peer_id) |
Looks up in the hello cache and returns the HELLO of the given peer. More... | |
void | GST_cache_add_hello (const unsigned int peer_id, const struct GNUNET_MessageHeader *hello) |
Caches the HELLO of the given peer. More... | |
Variables | |
static struct GNUNET_CONTAINER_MultiHashMap32 * | cache |
Hashmap to maintain cache. More... | |
static struct CacheEntry * | cache_head |
DLL head for least recently used cache entries; least recently used cache items are at the head. More... | |
static struct CacheEntry * | cache_tail |
DLL tail for least recently used cache entries; recently used cache items are at the tail.The cache enties are added to this queue when their demand becomes zero. More... | |
static unsigned int | cache_size |
Maximum number of elements to cache. More... | |
testbed cache implementation
Definition in file gnunet-service-testbed_cache.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "testbed-cache", __VA_ARGS__) |
Redefine LOG with a changed log component string.
Definition at line 35 of file gnunet-service-testbed_cache.c.
|
static |
Looks up in the cache and returns the entry.
peer_id | the peer identity of the peer whose corresponding entry has to be looked up |
Definition at line 101 of file gnunet-service-testbed_cache.c.
References cache, cache_head, cache_tail, GNUNET_assert, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multihashmap32_get(), and peer_id.
Referenced by GST_cache_add_hello(), and GST_cache_lookup_hello().
|
static |
Free the resources occupied by a cache entry.
entry | the cache entry to free |
Definition at line 121 of file gnunet-service-testbed_cache.c.
References cache_head, cache_tail, GNUNET_CONTAINER_DLL_remove, GNUNET_free, and CacheEntry::hello.
Referenced by add_entry(), and cache_clear_iterator().
|
static |
Creates a new cache entry and then puts it into the cache's hashtable.
peer_id | the index of the peer to tag the newly created entry |
Definition at line 136 of file gnunet-service-testbed_cache.c.
References cache, cache_head, cache_size, cache_tail, free_entry(), GNUNET_assert, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_CONTAINER_multihashmap32_put(), GNUNET_CONTAINER_multihashmap32_remove(), GNUNET_CONTAINER_multihashmap32_size(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_new, GNUNET_OK, peer_id, and CacheEntry::peer_id.
Referenced by GST_cache_add_hello().
|
static |
Iterator over hash map entries.
cls | closure |
key | current key |
value | value in the hash map |
Definition at line 174 of file gnunet-service-testbed_cache.c.
References cache, free_entry(), GNUNET_assert, GNUNET_CONTAINER_multihashmap32_remove(), GNUNET_YES, key, and value.
Referenced by GST_cache_clear().
void GST_cache_clear | ( | void | ) |
Clear cache.
Definition at line 190 of file gnunet-service-testbed_cache.c.
References cache, cache_clear_iterator(), cache_head, cache_size, cache_tail, GNUNET_assert, GNUNET_CONTAINER_multihashmap32_destroy(), GNUNET_CONTAINER_multihashmap32_iterate(), and GNUNET_CONTAINER_multihashmap32_size().
Referenced by shutdown_task().
void GST_cache_init | ( | unsigned int | size | ) |
Initializes the cache.
size | the size of the cache |
Definition at line 212 of file gnunet-service-testbed_cache.c.
References cache, cache_size, GNUNET_CONTAINER_multihashmap32_create(), and size.
Referenced by testbed_run().
const struct GNUNET_MessageHeader* GST_cache_lookup_hello | ( | const unsigned int | peer_id | ) |
Looks up in the hello cache and returns the HELLO of the given peer.
peer_id | the index of the peer whose HELLO has to be looked up |
Definition at line 228 of file gnunet-service-testbed_cache.c.
References cache, cache_lookup(), CacheEntry::hello, LOG_DEBUG, and peer_id.
Referenced by occ_cache_get_handle_core_cb().
void GST_cache_add_hello | ( | const unsigned int | peer_id, |
const struct GNUNET_MessageHeader * | hello | ||
) |
Caches the HELLO of the given peer.
Updates the HELLO if it was already cached before
peer_id | the peer identity of the peer whose HELLO has to be cached |
hello | the HELLO message |
Definition at line 255 of file gnunet-service-testbed_cache.c.
References add_entry(), cache, cache_lookup(), GNUNET_copy_message(), GNUNET_free, CacheEntry::hello, and peer_id.
Referenced by hello_update_cb().
|
static |
Hashmap to maintain cache.
Definition at line 69 of file gnunet-service-testbed_cache.c.
Referenced by add_entry(), cache_clear_iterator(), cache_lookup(), GNUNET_OS_check_helper_binary(), GNUNET_OS_get_libexec_binary_path(), GST_cache_add_hello(), GST_cache_clear(), GST_cache_init(), and GST_cache_lookup_hello().
|
static |
DLL head for least recently used cache entries; least recently used cache items are at the head.
The cache enties are added to this queue when their demand becomes zero. They are removed from the queue when they are needed by any operation.
Definition at line 77 of file gnunet-service-testbed_cache.c.
Referenced by add_entry(), cache_lookup(), free_entry(), and GST_cache_clear().
|
static |
DLL tail for least recently used cache entries; recently used cache items are at the tail.The cache enties are added to this queue when their demand becomes zero.
They are removed from the queue when they are needed by any operation.
Definition at line 85 of file gnunet-service-testbed_cache.c.
Referenced by add_entry(), cache_lookup(), free_entry(), and GST_cache_clear().
|
static |
Maximum number of elements to cache.
Definition at line 90 of file gnunet-service-testbed_cache.c.
Referenced by add_entry(), GST_cache_clear(), and GST_cache_init().