diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-10-20 14:29:46 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-10-20 19:43:32 +0100 |
commit | 5bdc64980877fdc234eba3419a3a596eddc0dc7f (patch) | |
tree | e82fcbb8626fecb7d511e9b4785890a48d7650da /src/libserver | |
parent | 450179f942070bf750514d43dd091ed529475739 (diff) | |
download | rspamd-5bdc64980877fdc234eba3419a3a596eddc0dc7f.tar.gz rspamd-5bdc64980877fdc234eba3419a3a596eddc0dc7f.zip |
[Project] Add logic of the async events counter
Diffstat (limited to 'src/libserver')
-rw-r--r-- | src/libserver/symbols_cache.c | 23 | ||||
-rw-r--r-- | src/libserver/symbols_cache.h | 18 |
2 files changed, 32 insertions, 9 deletions
diff --git a/src/libserver/symbols_cache.c b/src/libserver/symbols_cache.c index b5db5c7f9..216f8aabf 100644 --- a/src/libserver/symbols_cache.c +++ b/src/libserver/symbols_cache.c @@ -2641,7 +2641,7 @@ rspamd_symbols_cache_finalize_item (struct rspamd_task *task, g_assert (checkpoint->items_inflight > 0); g_assert (item->async_events == 0); - msg_debug_cache_task ("process post" + msg_debug_cache_task ("process finalize for item %s", item->symbol); setbit (checkpoint->processed_bits, item->id + 1); checkpoint->items_inflight --; @@ -2679,8 +2679,8 @@ rspamd_symbols_cache_finalize_item (struct rspamd_task *task, } guint -rspamd_symcahe_item_async_inc (struct rspamd_task *task, - struct rspamd_symcache_item *item) +rspamd_symcache_item_async_inc (struct rspamd_task *task, + struct rspamd_symcache_item *item) { msg_debug_cache_task ("increase async events counter for %s = %d + 1", item->symbol, item->async_events); @@ -2688,12 +2688,25 @@ rspamd_symcahe_item_async_inc (struct rspamd_task *task, } guint -rspamd_symcahe_item_async_dec (struct rspamd_task *task, - struct rspamd_symcache_item *item) +rspamd_symcache_item_async_dec (struct rspamd_task *task, + struct rspamd_symcache_item *item) { msg_debug_cache_task ("decrease async events counter for %s = %d - 1", item->symbol, item->async_events); g_assert (item->async_events > 0); return --item->async_events; +} + +gboolean +rspamd_symcache_item_async_dec_check (struct rspamd_task *task, + struct rspamd_symcache_item *item) +{ + if (rspamd_symcache_item_async_dec (task, item) == 0) { + rspamd_symbols_cache_finalize_item (task, item); + + return TRUE; + } + + return FALSE; }
\ No newline at end of file diff --git a/src/libserver/symbols_cache.h b/src/libserver/symbols_cache.h index adf7d2b26..5845840ab 100644 --- a/src/libserver/symbols_cache.h +++ b/src/libserver/symbols_cache.h @@ -335,11 +335,21 @@ void rspamd_symbols_cache_finalize_item (struct rspamd_task *task, /* * Increase number of async events pending for an item */ -guint rspamd_symcahe_item_async_inc (struct rspamd_task *task, - struct rspamd_symcache_item *item); +guint rspamd_symcache_item_async_inc (struct rspamd_task *task, + struct rspamd_symcache_item *item); /* * Decrease number of async events pending for an item, asserts if no events pending */ -guint rspamd_symcahe_item_async_dec (struct rspamd_task *task, - struct rspamd_symcache_item *item); +guint rspamd_symcache_item_async_dec (struct rspamd_task *task, + struct rspamd_symcache_item *item); + +/** + * Decrease number of async events pending for an item, asserts if no events pending + * If no events are left, this function calls `rspamd_symbols_cache_finalize_item` and returns TRUE + * @param task + * @param item + * @return + */ +gboolean rspamd_symcache_item_async_dec_check (struct rspamd_task *task, + struct rspamd_symcache_item *item); #endif |