summaryrefslogtreecommitdiff
path: root/res/res_sorcery_memory_cache.c
diff options
context:
space:
mode:
authorMatt Jordan <mjordan@digium.com>2015-06-05 18:04:24 -0500
committerGerrit Code Review <gerrit2@gerrit.digium.api>2015-06-05 18:04:25 -0500
commit8785d0ccbfa1959d1ba6be8769e9d5356f3fef32 (patch)
tree38d8838f67768f1d90cdce496ba5a9d08cd2d9e7 /res/res_sorcery_memory_cache.c
parent5788c6db6755d26fc06ef87de7c6d5e43ae41bea (diff)
parent028edae82e6c94cd4dce1d699c4e41d758ef9427 (diff)
Merge "test_sorcery_memory_cache_thrash: Add unit tests for thrashing the memory cache."
Diffstat (limited to 'res/res_sorcery_memory_cache.c')
-rw-r--r--res/res_sorcery_memory_cache.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/res/res_sorcery_memory_cache.c b/res/res_sorcery_memory_cache.c
index 10ef59a35..26df12a69 100644
--- a/res/res_sorcery_memory_cache.c
+++ b/res/res_sorcery_memory_cache.c
@@ -418,6 +418,9 @@ static int remove_from_cache(struct sorcery_memory_cache *cache, const char *id,
if (!hash_object) {
return -1;
}
+
+ ast_assert(!strcmp(ast_sorcery_object_get_id(hash_object->object), id));
+
oldest_object = ast_heap_peek(cache->object_heap, 1);
heap_object = ast_heap_remove(cache->object_heap, hash_object);
@@ -537,6 +540,8 @@ static int mark_object_as_stale_in_cache(struct sorcery_memory_cache *cache, con
return -1;
}
+ ast_assert(!strcmp(ast_sorcery_object_get_id(cached->object), id));
+
object_stale_callback(cached, cache, 0);
ao2_ref(cached, -1);
@@ -718,6 +723,7 @@ static int sorcery_memory_cache_create(const struct ast_sorcery *sorcery, void *
ao2_unlock(cache->objects);
return -1;
}
+ ast_assert(ao2_container_count(cache->objects) != cache->maximum_objects);
}
if (add_to_cache(cache, cached)) {
ast_log(LOG_ERROR, "Unable to add object '%s' to the cache\n",
@@ -826,6 +832,8 @@ static void *sorcery_memory_cache_retrieve_id(const struct ast_sorcery *sorcery,
return NULL;
}
+ ast_assert(!strcmp(ast_sorcery_object_get_id(cached->object), id));
+
if (cache->object_lifetime_stale) {
struct timeval elapsed;