]> source.dussan.org Git - rspamd.git/commitdiff
Write to log number of dns requests per task.
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Fri, 25 Mar 2011 16:13:20 +0000 (19:13 +0300)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Fri, 25 Mar 2011 16:13:20 +0000 (19:13 +0300)
src/lua/lua_task.c
src/main.h
src/plugins/surbl.c
src/protocol.c
src/spf.c

index 339f9e23f9bc881bafaf6669fa5f7150ee331615..a0e6a3992ffd9f352f72a0e40a102edd0da8b903 100644 (file)
@@ -571,6 +571,7 @@ lua_task_resolve_dns_a (lua_State * L)
                        return 0;
                }
                if (make_dns_request (task->resolver, task->s, task->task_pool, lua_dns_callback, (void *)cd, DNS_REQUEST_A, cd->to_resolve)) {
+                       task->dns_requests ++;
                        task->save.saved++;
                }
        }
@@ -612,6 +613,7 @@ lua_task_resolve_dns_txt (lua_State * L)
                        return 0;
                }
                if (make_dns_request (task->resolver, task->s, task->task_pool, lua_dns_callback, (void *)cd, DNS_REQUEST_TXT, cd->to_resolve)) {
+                       task->dns_requests ++;
                        task->save.saved++;
                }
        }
@@ -655,6 +657,7 @@ lua_task_resolve_dns_ptr (lua_State * L)
                        return 0;
                }
                if (make_dns_request (task->resolver, task->s, task->task_pool, lua_dns_callback, (void *)cd, DNS_REQUEST_PTR, ina)) {
+                       task->dns_requests ++;
                        task->save.saved++;
                }
        }
index e6cf670789b0461fd0a1ea276aa163192c819bec..02bebf89a14ce86e607a017a7a5a8a9ffc21c76f 100644 (file)
@@ -229,6 +229,8 @@ struct worker_task {
        gboolean (*fin_callback)(void *arg);                                            /**< calback for filters finalizing                                     */
        void *fin_arg;                                                                                          /**< argument for fin callback                                          */
 
+       guint32 dns_requests;                                                                           /**< number of DNS requests per this task                       */
+
        struct rspamd_dns_resolver *resolver;                                           /**< DNS resolver                                                                       */
 };
 
index d3763822c7310fc569613a0ede170e026bb579d0..6266e61eb1ac054bc6be6638477fe292b6b4bd46 100644 (file)
@@ -605,6 +605,7 @@ make_surbl_requests (struct uri *url, struct worker_task *task,
                        param->host_resolve = memory_pool_strdup (task->task_pool, surbl_req);
                        debug_task ("send surbl dns request %s", surbl_req);
                        if (make_dns_request (task->resolver, task->s, task->task_pool, dns_callback, (void *)param, DNS_REQUEST_A, surbl_req)) {
+                               task->dns_requests ++;
                                param->task->save.saved++;
                        }
                }
index f6b0c30fc09cc95a131b4256b00b998186f7d5fd..edeec92b9f0930e6fce2582580e1949741f2e4ee 100644 (file)
@@ -821,12 +821,13 @@ show_metric_result (gpointer metric_name, gpointer metric_value, void *user_data
        }
 #ifdef HAVE_CLOCK_GETTIME
        cd->log_offset += rspamd_snprintf (cd->log_buf + cd->log_offset,
-                       cd->log_size - cd->log_offset, "]), len: %z, time: %s,",
+                       cd->log_size - cd->log_offset, "]), len: %z, time: %s, dns req: %d,",
                        task->msg->len, calculate_check_time (&task->tv, &task->ts,
-                                       task->cfg->clock_res));
+                                       task->cfg->clock_res), task->dns_requests);
 #else
-       cd->log_offset += rspamd_snprintf (cd->log_buf + cd->log_offset, cd->log_size - cd->log_offset, "]), len: %z, time: %s,",
-                       task->msg->len, calculate_check_time (&task->tv, task->cfg->clock_res));
+       cd->log_offset += rspamd_snprintf (cd->log_buf + cd->log_offset, cd->log_size - cd->log_offset,
+                       "]), len: %z, time: %s, dns req: %d,",
+                       task->msg->len, calculate_check_time (&task->tv, task->cfg->clock_res), task->dns_requests);
 #endif
 }
 
index 233025ca3f013b9b78456688d72eb8faceccc559..7c0e82ec6e4a2cd606968a12df270fc237b5ea49 100644 (file)
--- a/src/spf.c
+++ b/src/spf.c
@@ -340,6 +340,7 @@ spf_record_dns_callback (struct rspamd_dns_reply *reply, gpointer arg)
                                        if (reply->type == DNS_REQUEST_MX) {
                                                /* Now resolve A record for this MX */
                                                if (make_dns_request (task->resolver, task->s, task->task_pool, spf_record_dns_callback, (void *)cb, DNS_REQUEST_A, elt_data->mx.name)) {
+                                                       task->dns_requests ++;
                                                        task->save.saved++;
                                                }
                                        }
@@ -492,6 +493,7 @@ parse_spf_a (struct worker_task *task, const gchar *begin, struct spf_record *re
        cb->cur_action = SPF_RESOLVE_A;
        cb->in_include = rec->in_include;
        if (make_dns_request (task->resolver, task->s, task->task_pool, spf_record_dns_callback, (void *)cb, DNS_REQUEST_A, host)) {
+               task->dns_requests ++;
                task->save.saved++;
                
                return TRUE;
@@ -539,6 +541,7 @@ parse_spf_mx (struct worker_task *task, const gchar *begin, struct spf_record *r
        cb->cur_action = SPF_RESOLVE_MX;
        cb->in_include = rec->in_include;
        if (make_dns_request (task->resolver, task->s, task->task_pool, spf_record_dns_callback, (void *)cb, DNS_REQUEST_MX, host)) {
+               task->dns_requests ++;
                task->save.saved++;
                
                return TRUE;
@@ -596,6 +599,7 @@ parse_spf_include (struct worker_task *task, const gchar *begin, struct spf_reco
        addr->data.list = NULL;
        domain = memory_pool_strdup (task->task_pool, begin);
        if (make_dns_request (task->resolver, task->s, task->task_pool, spf_record_dns_callback, (void *)cb, DNS_REQUEST_TXT, domain)) {
+               task->dns_requests ++;
                task->save.saved++;
                
                return TRUE;
@@ -635,6 +639,7 @@ parse_spf_redirect (struct worker_task *task, const gchar *begin, struct spf_rec
        cb->in_include = rec->in_include;
        domain = memory_pool_strdup (task->task_pool, begin);
        if (make_dns_request (task->resolver, task->s, task->task_pool, spf_record_dns_callback, (void *)cb, DNS_REQUEST_TXT, domain)) {
+               task->dns_requests ++;
                task->save.saved++;
                
                return TRUE;
@@ -666,6 +671,7 @@ parse_spf_exists (struct worker_task *task, const gchar *begin, struct spf_recor
        host = memory_pool_strdup (task->task_pool, begin);
 
        if (make_dns_request (task->resolver, task->s, task->task_pool, spf_record_dns_callback, (void *)cb, DNS_REQUEST_A, host)) {
+               task->dns_requests ++;
                task->save.saved++;
                
                return TRUE;
@@ -1195,6 +1201,7 @@ resolve_spf (struct worker_task *task, spf_cb_t callback)
                rec->sender_domain = rec->cur_domain;
 
                if (make_dns_request (task->resolver, task->s, task->task_pool, spf_dns_callback, (void *)rec, DNS_REQUEST_TXT, rec->cur_domain)) {
+                       task->dns_requests ++;
                        task->save.saved++;
                        return TRUE;
                }
@@ -1224,6 +1231,7 @@ resolve_spf (struct worker_task *task, spf_cb_t callback)
                        }
                        rec->sender_domain = rec->cur_domain;
                        if (make_dns_request (task->resolver, task->s, task->task_pool, spf_dns_callback, (void *)rec, DNS_REQUEST_TXT, rec->cur_domain)) {
+                               task->dns_requests ++;
                                task->save.saved++;
                                return TRUE;
                        }