]> source.dussan.org Git - rspamd.git/commitdiff
Make hash traversing more safe by using reference count.
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Fri, 5 Aug 2011 10:52:21 +0000 (14:52 +0400)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Fri, 5 Aug 2011 10:52:21 +0000 (14:52 +0400)
Update to 0.4.2

CMakeLists.txt
src/filter.c
src/protocol.c

index 09ca242758f0858f92aa2a37b7a25181c828cfa8..3ed111e593353d2ba268b5971a3ba659a9808b14 100644 (file)
@@ -7,7 +7,7 @@ PROJECT(rspamd C)
 
 SET(RSPAMD_VERSION_MAJOR 0)
 SET(RSPAMD_VERSION_MINOR 4)
-SET(RSPAMD_VERSION_PATCH 1)
+SET(RSPAMD_VERSION_PATCH 2)
 
 
 SET(RSPAMD_VERSION         "${RSPAMD_VERSION_MAJOR}.${RSPAMD_VERSION_MINOR}.${RSPAMD_VERSION_PATCH}")
index 17dc6aa6017256b2ae9173fabe99be6d558e4c49..c0c21681d20bbdc1ad23f94a86ccb9640d260838 100644 (file)
@@ -64,7 +64,7 @@ insert_metric_result (struct worker_task *task, struct metric *metric, const gch
                metric_res = memory_pool_alloc (task->task_pool, sizeof (struct metric_result));
                metric_res->symbols = g_hash_table_new (g_str_hash, g_str_equal);
                metric_res->checked = FALSE;
-               memory_pool_add_destructor (task->task_pool, (pool_destruct_func) g_hash_table_destroy, metric_res->symbols);
+               memory_pool_add_destructor (task->task_pool, (pool_destruct_func) g_hash_table_unref, metric_res->symbols);
                metric_res->metric = metric;
                metric_res->grow_factor = 0;
                metric_res->score = 0;
@@ -663,7 +663,7 @@ process_statfiles (struct worker_task *task)
 
        if (task->tokens == NULL) {
                task->tokens = g_hash_table_new (g_direct_hash, g_direct_equal);
-               memory_pool_add_destructor (task->task_pool, (pool_destruct_func)g_hash_table_destroy, task->tokens);
+               memory_pool_add_destructor (task->task_pool, (pool_destruct_func)g_hash_table_unref, task->tokens);
        }
 
        g_list_foreach (task->cfg->classifiers, classifiers_callback, task);
index a037e2b01db578c104a07326bb3075ca5452c91f..5c85a4a7d6750fe2b253325bf83079e9e47072a0 100644 (file)
@@ -829,7 +829,9 @@ show_metric_symbols_rspamc (struct metric_result *metric_res, struct metric_call
 {
        cd->cur_metric = metric_res->metric;
        if (cd->alive) {
+               g_hash_table_ref (metric_res->symbols);
                g_hash_table_foreach (metric_res->symbols, metric_symbols_callback_rspamc, cd);
+               g_hash_table_unref (metric_res->symbols);
                /* Remove last , from log buf */
                if (cd->log_buf[cd->log_offset - 1] == ',') {
                        cd->log_buf[--cd->log_offset] = '\0';
@@ -899,7 +901,9 @@ show_metric_symbols_json (struct metric_result *metric_res, struct metric_callba
                        "    \"symbols\": [");
 
        /* Print all symbols */
+       g_hash_table_ref (metric_res->symbols);
        g_hash_table_foreach (metric_res->symbols, metric_symbols_callback_json, cd);
+       g_hash_table_unref (metric_res->symbols);
        /* Remove last ',' symbol */
        if (cd->symbols_buf[cd->symbols_offset - 1] == ',') {
                        cd->symbols_buf[--cd->symbols_offset] = '\0';
@@ -1314,7 +1318,9 @@ write_check_reply (struct worker_task *task)
                g_hash_table_remove (task->results, "default");
 
                /* Write result for each metric separately */
+               g_hash_table_ref (task->results);
                g_hash_table_foreach (task->results, show_metric_result, &cd);
+               g_hash_table_unref (task->results);
                if (!cd.alive) {
                        return FALSE;
                }
@@ -1468,7 +1474,9 @@ write_process_reply (struct worker_task *task)
                g_hash_table_remove (task->results, "default");
 
                /* Write result for each metric separately */
+               g_hash_table_ref (task->results);
                g_hash_table_foreach (task->results, show_metric_result, &cd);
+               g_hash_table_unref (task->results);
                if (! cd.alive) {
                        return FALSE;
                }