diff --git a/res/res_sorcery_memory_cache.c b/res/res_sorcery_memory_cache.c index dad3146283..bdcb38bdf1 100644 --- a/res/res_sorcery_memory_cache.c +++ b/res/res_sorcery_memory_cache.c @@ -483,6 +483,7 @@ static int remove_from_cache(struct sorcery_memory_cache *cache, const char *id, ao2_ref(hash_object, -1); if (reschedule && (oldest_object == heap_object)) { + ast_log(LOG_TRACE, "Call to 'schedule_cache_expiration' '%s'\n", cache->name); schedule_cache_expiration(cache); } @@ -499,6 +500,7 @@ static int expire_objects_from_cache(const void *data) { struct sorcery_memory_cache *cache = (struct sorcery_memory_cache *)data; struct sorcery_memory_cached_object *cached; + ast_log(LOG_TRACE, "Entering 'expire_objects_from_cache' for cache '%s'\n", cache->name); /* * We need to do deadlock avoidance between a non-scheduler thread @@ -511,6 +513,7 @@ static int expire_objects_from_cache(const void *data) if (cache->del_expire) { cache->expire_id = -1; ao2_ref(cache, -1); + ast_log(LOG_TRACE, "Exiting 'expire_objects_from_cache' for cache '%s' without securing lock\n", cache->name); return 0; } sched_yield(); @@ -532,12 +535,14 @@ static int expire_objects_from_cache(const void *data) remove_from_cache(cache, ast_sorcery_object_get_id(cached->object), 0); } + ast_log(LOG_TRACE, "Call to 'schedule_cache_expiration' for cache '%s'\n", cache->name); schedule_cache_expiration(cache); ao2_unlock(cache->objects); ao2_ref(cache, -1); + ast_log(LOG_TRACE, "Exiting 'expire_objects_from_cache' for cache '%s' after securing lock\n", cache->name); return 0; } @@ -553,6 +558,7 @@ static int expire_objects_from_cache(const void *data) */ static void remove_all_from_cache(struct sorcery_memory_cache *cache) { + ast_log(LOG_TRACE, "Entering 'remove_all_from_cache' for cache '%s'\n", cache->name); while (ast_heap_pop(cache->object_heap)) { } @@ -562,6 +568,7 @@ static void remove_all_from_cache(struct sorcery_memory_cache *cache) cache->del_expire = 1; AST_SCHED_DEL_UNREF(sched, cache->expire_id, ao2_ref(cache, -1)); cache->del_expire = 0; + ast_log(LOG_TRACE, "Exiting 'remove_all_from_cache' for cache '%s'\n", cache->name); } /*! @@ -649,8 +656,10 @@ static int schedule_cache_expiration(struct sorcery_memory_cache *cache) { struct sorcery_memory_cached_object *cached; int expiration = 0; + ast_log(LOG_TRACE, "Entering 'schedule_cache_expiration' for cache '%s'\n", cache->name); if (!cache->object_lifetime_maximum) { + ast_log(LOG_TRACE, "Exiting 'schedule_cache_expiration' for cache '%s' due to object_lifetime_maximum\n", cache->name); return 0; } @@ -666,18 +675,22 @@ static int schedule_cache_expiration(struct sorcery_memory_cache *cache) ast_cond_signal(&cache->cond); ast_mutex_unlock(&cache->lock); #endif + ast_log(LOG_TRACE, "Exiting 'schedule_cache_expiration' for cache '%s' due to not found in heap\n", cache->name); return 0; } expiration = MAX(ast_tvdiff_ms(ast_tvadd(cached->created, ast_samp2tv(cache->object_lifetime_maximum, 1)), ast_tvnow()), 1); + ast_log(LOG_TRACE, "ast_sched_add for 'expire_objects_from_cache' for cache '%s'\n", cache->name); cache->expire_id = ast_sched_add(sched, expiration, expire_objects_from_cache, ao2_bump(cache)); if (cache->expire_id < 0) { ao2_ref(cache, -1); + ast_log(LOG_TRACE, "Exiting 'remove_all_from_cache' for cache '%s'\n due to expire_id being less than 0", cache->name); return -1; } + ast_log(LOG_TRACE, "Exiting 'schedule_cache_expiration' for cache '%s'\n", cache->name); return 0; } @@ -708,6 +721,7 @@ static int remove_oldest_from_cache(struct sorcery_memory_cache *cache) ao2_ref(hash_old_object, -1); + ast_log(LOG_TRACE, "Call to 'schedule_cache_expiration' for cache '%s'\n", cache->name); schedule_cache_expiration(cache); return 0; @@ -746,6 +760,7 @@ static int add_to_cache(struct sorcery_memory_cache *cache, } if (cache->expire_id == -1) { + ast_log(LOG_TRACE, "Call to 'schedule_cache_expiration' for cache '%s'\n", cache->name); schedule_cache_expiration(cache); }