diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2022-04-30 13:42:38 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2022-04-30 13:42:38 +0100 |
commit | d2f5129241523754c8f722648ca4331ce8d0a8bc (patch) | |
tree | af349c58019883fe12c5bedfb4f6f619b62fa2f1 /src/libserver/symcache/symcache_c.cxx | |
parent | e7502bb0f28022eb985e4c7661a4de36391bd985 (diff) | |
download | rspamd-d2f5129241523754c8f722648ca4331ce8d0a8bc.tar.gz rspamd-d2f5129241523754c8f722648ca4331ce8d0a8bc.zip |
[Project] Implement more methods
Diffstat (limited to 'src/libserver/symcache/symcache_c.cxx')
-rw-r--r-- | src/libserver/symcache/symcache_c.cxx | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/src/libserver/symcache/symcache_c.cxx b/src/libserver/symcache/symcache_c.cxx index 4547f23a4..ba3ccd9a6 100644 --- a/src/libserver/symcache/symcache_c.cxx +++ b/src/libserver/symcache/symcache_c.cxx @@ -433,7 +433,7 @@ rspamd_symcache_set_cur_item(struct rspamd_task *task, struct rspamd_symcache_it auto *cache_runtime = C_API_SYMCACHE_RUNTIME(task->symcache_runtime); auto *real_item = C_API_SYMCACHE_ITEM(item); - return (struct rspamd_symcache_item *)cache_runtime->set_cur_item(real_item); + return (struct rspamd_symcache_item *) cache_runtime->set_cur_item(real_item); } void @@ -494,4 +494,38 @@ rspamd_symcache_item_async_dec_check_full(struct rspamd_task *task, } return FALSE; +} + +struct rspamd_abstract_callback_data * +rspamd_symcache_get_cbdata(struct rspamd_symcache *cache, + const gchar *symbol) +{ + auto *real_cache = C_API_SYMCACHE(cache); + + auto *item = real_cache->get_item_by_name(symbol, true); + + if (item) { + return (struct rspamd_abstract_callback_data *) item->get_cbdata(); + } + + return nullptr; +} + +void +rspamd_symcache_composites_foreach(struct rspamd_task *task, + struct rspamd_symcache *cache, + GHFunc func, + gpointer fd) +{ + auto *real_cache = C_API_SYMCACHE(cache); + auto *cache_runtime = C_API_SYMCACHE_RUNTIME(task->symcache_runtime); + + real_cache->composites_foreach([&](const auto *item) { + auto *dyn_item = cache_runtime->get_dynamic_item(item->id, false); + + if (dyn_item->started) { + func((void *)item->get_name().c_str(), item->get_cbdata(), fd); + dyn_item->finished = true; + } + }); }
\ No newline at end of file |