aboutsummaryrefslogtreecommitdiffstats
path: root/src/protocol.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2011-08-05 14:52:21 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2011-08-05 14:52:21 +0400
commitf5867bfec49caebbe06b3058fd905dd243f07438 (patch)
treed56cc45d24b733e30672b1c556d628d2c481601b /src/protocol.c
parent6c4d8488b1322b6e53bc1f0beac94b790b34c5ae (diff)
downloadrspamd-f5867bfec49caebbe06b3058fd905dd243f07438.tar.gz
rspamd-f5867bfec49caebbe06b3058fd905dd243f07438.zip
Make hash traversing more safe by using reference count.
Update to 0.4.2
Diffstat (limited to 'src/protocol.c')
-rw-r--r--src/protocol.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/protocol.c b/src/protocol.c
index a037e2b01..5c85a4a7d 100644
--- a/src/protocol.c
+++ b/src/protocol.c
@@ -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;
}