diff options
-rw-r--r-- | src/libserver/dkim.c | 7 | ||||
-rw-r--r-- | src/libserver/dkim.h | 3 | ||||
-rw-r--r-- | src/libserver/spf.c | 38 | ||||
-rw-r--r-- | src/lua/lua_http.c | 21 | ||||
-rw-r--r-- | src/lua/lua_tcp.c | 17 | ||||
-rw-r--r-- | src/plugins/dkim_check.c | 4 | ||||
-rw-r--r-- | src/plugins/surbl.c | 3 |
7 files changed, 46 insertions, 47 deletions
diff --git a/src/libserver/dkim.c b/src/libserver/dkim.c index 709180817..7074fb509 100644 --- a/src/libserver/dkim.c +++ b/src/libserver/dkim.c @@ -995,8 +995,7 @@ rspamd_dkim_dns_cb (struct rdns_reply *reply, gpointer arg) */ gboolean rspamd_get_dkim_key (rspamd_dkim_context_t *ctx, - struct rspamd_dns_resolver *resolver, - struct rspamd_async_session *s, + struct rspamd_task *task, dkim_key_handler_f handler, gpointer ud) { @@ -1012,9 +1011,7 @@ rspamd_get_dkim_key (rspamd_dkim_context_t *ctx, cbdata->handler = handler; cbdata->ud = ud; - return make_dns_request (resolver, - s, - ctx->pool, + return make_dns_request_task (task, rspamd_dkim_dns_cb, cbdata, RDNS_REQUEST_TXT, diff --git a/src/libserver/dkim.h b/src/libserver/dkim.h index 8305e2e4a..07d9483fc 100644 --- a/src/libserver/dkim.h +++ b/src/libserver/dkim.h @@ -191,8 +191,7 @@ rspamd_dkim_context_t * rspamd_create_dkim_context (const gchar *sig, * @return */ gboolean rspamd_get_dkim_key (rspamd_dkim_context_t *ctx, - struct rspamd_dns_resolver *resolver, - struct rspamd_async_session *s, + struct rspamd_task *task, dkim_key_handler_f handler, gpointer ud); diff --git a/src/libserver/spf.c b/src/libserver/spf.c index f324454ae..3df504f94 100644 --- a/src/libserver/spf.c +++ b/src/libserver/spf.c @@ -452,18 +452,15 @@ spf_record_dns_callback (struct rdns_reply *reply, gpointer arg) /* Now resolve A record for this MX */ msg_debug ("resolve %s after resolving of MX", elt_data->content.mx.name); - if (make_dns_request (task->resolver, task->s, - task->task_pool, + if (make_dns_request_task (task, spf_record_dns_callback, (void *)cb, RDNS_REQUEST_A, elt_data->content.mx.name)) { - task->dns_requests++; cb->rec->requests_inflight++; } - if (make_dns_request (task->resolver, task->s, - task->task_pool, + + if (make_dns_request_task (task, spf_record_dns_callback, (void *)cb, RDNS_REQUEST_AAAA, elt_data->content.mx.name)) { - task->dns_requests++; cb->rec->requests_inflight++; } } @@ -481,20 +478,16 @@ spf_record_dns_callback (struct rdns_reply *reply, gpointer arg) if (spf_check_ptr_host (cb, elt_data->content.ptr.name)) { msg_debug ("resolve %s after resolving of PTR", elt_data->content.ptr.name); - if (make_dns_request (task->resolver, task->s, - task->task_pool, + if (make_dns_request_task (task, spf_record_dns_callback, (void *)cb, RDNS_REQUEST_A, elt_data->content.ptr.name)) { - task->dns_requests++; cb->rec->requests_inflight++; } - if (make_dns_request (task->resolver, task->s, - task->task_pool, + if (make_dns_request_task (task, spf_record_dns_callback, (void *)cb, RDNS_REQUEST_AAAA, elt_data->content.ptr.name)) { - task->dns_requests++; cb->rec->requests_inflight++; } } @@ -759,9 +752,8 @@ parse_spf_a (struct spf_record *rec, struct spf_addr *addr) cb->resolved = resolved; msg_debug ("resolve a %s", host); - if (make_dns_request (task->resolver, task->s, task->task_pool, + if (make_dns_request_task (task, spf_record_dns_callback, (void *)cb, RDNS_REQUEST_A, host)) { - task->dns_requests++; rec->requests_inflight++; return TRUE; } @@ -801,9 +793,8 @@ parse_spf_ptr (struct spf_record *rec, struct spf_addr *addr) rspamd_mempool_add_destructor (task->task_pool, free, ptr); msg_debug ("resolve ptr %s for %s", ptr, host); - if (make_dns_request (task->resolver, task->s, task->task_pool, + if (make_dns_request_task (task, spf_record_dns_callback, (void *)cb, RDNS_REQUEST_PTR, ptr)) { - task->dns_requests++; rec->requests_inflight++; return TRUE; @@ -838,9 +829,8 @@ parse_spf_mx (struct spf_record *rec, struct spf_addr *addr) cb->resolved = resolved; msg_debug ("resolve mx for %s", host); - if (make_dns_request (task->resolver, task->s, task->task_pool, + if (make_dns_request_task (task, spf_record_dns_callback, (void *)cb, RDNS_REQUEST_MX, host)) { - task->dns_requests++; rec->requests_inflight++; return TRUE; @@ -989,9 +979,8 @@ parse_spf_include (struct spf_record *rec, struct spf_addr *addr) addr->flags |= RSPAMD_SPF_FLAG_REFRENCE; msg_debug ("resolve include %s", domain); - if (make_dns_request (task->resolver, task->s, task->task_pool, + if (make_dns_request_task (task, spf_record_dns_callback, (void *)cb, RDNS_REQUEST_TXT, domain)) { - task->dns_requests++; rec->requests_inflight++; return TRUE; @@ -1053,9 +1042,8 @@ parse_spf_redirect (struct spf_record *rec, cb->resolved = rspamd_spf_new_addr_list (rec, domain); msg_debug ("resolve redirect %s", domain); - if (make_dns_request (task->resolver, task->s, task->task_pool, + if (make_dns_request_task (task, spf_record_dns_callback, (void *)cb, RDNS_REQUEST_TXT, domain)) { - task->dns_requests++; rec->requests_inflight++; return TRUE; @@ -1091,9 +1079,8 @@ parse_spf_exists (struct spf_record *rec, struct spf_addr *addr) cb->resolved = resolved; msg_debug ("resolve exists %s", host); - if (make_dns_request (task->resolver, task->s, task->task_pool, + if (make_dns_request_task (task, spf_record_dns_callback, (void *)cb, RDNS_REQUEST_A, host)) { - task->dns_requests++; rec->requests_inflight++; return TRUE; @@ -1694,10 +1681,9 @@ resolve_spf (struct rspamd_task *task, spf_cb_t callback) return FALSE; } - if (make_dns_request (task->resolver, task->s, task->task_pool, + if (make_dns_request_task (task, spf_dns_callback, (void *)rec, RDNS_REQUEST_TXT, rec->sender_domain)) { - task->dns_requests++; rec->requests_inflight++; return TRUE; } diff --git a/src/lua/lua_http.c b/src/lua/lua_http.c index 71cc35f15..427a23827 100644 --- a/src/lua/lua_http.c +++ b/src/lua/lua_http.c @@ -458,12 +458,23 @@ lua_http_request (lua_State *L) } } else { - if (!make_dns_request (resolver, session, NULL, lua_http_dns_handler, cbd, - RDNS_REQUEST_A, msg->host->str)) { - lua_http_maybe_free (cbd); - lua_pushboolean (L, FALSE); + if (task == NULL) { + if (!make_dns_request (resolver, session, NULL, lua_http_dns_handler, cbd, + RDNS_REQUEST_A, msg->host->str)) { + lua_http_maybe_free (cbd); + lua_pushboolean (L, FALSE); - return 1; + return 1; + } + } + else { + if (!make_dns_request_task (task, lua_http_dns_handler, cbd, + RDNS_REQUEST_A, msg->host->str)) { + lua_http_maybe_free (cbd); + lua_pushboolean (L, FALSE); + + return 1; + } } } diff --git a/src/lua/lua_tcp.c b/src/lua/lua_tcp.c index 43e8cab7e..030f3109b 100644 --- a/src/lua/lua_tcp.c +++ b/src/lua/lua_tcp.c @@ -610,10 +610,19 @@ lua_tcp_request (lua_State *L) } } else { - if (!make_dns_request (resolver, session, NULL, lua_tcp_dns_handler, cbd, - RDNS_REQUEST_A, host)) { - lua_tcp_push_error (cbd, "cannot resolve host"); - lua_tcp_maybe_free (cbd); + if (task == NULL) { + if (!make_dns_request (resolver, session, NULL, lua_tcp_dns_handler, cbd, + RDNS_REQUEST_A, host)) { + lua_tcp_push_error (cbd, "cannot resolve host"); + lua_tcp_maybe_free (cbd); + } + } + else { + if (!make_dns_request_task (task, lua_tcp_dns_handler, cbd, + RDNS_REQUEST_A, host)) { + lua_tcp_push_error (cbd, "cannot resolve host"); + lua_tcp_maybe_free (cbd); + } } } diff --git a/src/plugins/dkim_check.c b/src/plugins/dkim_check.c index 50b2a4c21..477a1bc29 100644 --- a/src/plugins/dkim_check.c +++ b/src/plugins/dkim_check.c @@ -502,10 +502,8 @@ dkim_symbol_callback (struct rspamd_task *task, void *unused) } else { debug_task ("request key for %s from DNS", ctx->dns_key); - task->dns_requests++; rspamd_get_dkim_key (ctx, - task->resolver, - task->s, + task, dkim_module_key_handler, cur); } diff --git a/src/plugins/surbl.c b/src/plugins/surbl.c index 233e7bbb8..23beb1fbc 100644 --- a/src/plugins/surbl.c +++ b/src/plugins/surbl.c @@ -856,10 +856,9 @@ make_surbl_requests (struct rspamd_url *url, struct rspamd_task *task, rspamd_mempool_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, + if (make_dns_request_task (task, dns_callback, (void *)param, RDNS_REQUEST_A, surbl_req)) { - task->dns_requests++; param->w = rspamd_session_get_watcher (task->s); rspamd_session_watcher_push (task->s); } |