aboutsummaryrefslogtreecommitdiffstats
path: root/src/dns.h
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2013-12-18 11:11:36 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2013-12-18 11:11:36 +0000
commitbab9cbb4683069f7b00daf11581b578f1d17ae0b (patch)
tree494003eaa4d4e4a119006516af521b470d39e88a /src/dns.h
parentaa1438ae5a373d9775c228443e30da6e41df8ae9 (diff)
downloadrspamd-bab9cbb4683069f7b00daf11581b578f1d17ae0b.tar.gz
rspamd-bab9cbb4683069f7b00daf11581b578f1d17ae0b.zip
Use sockets pool for DNS requests.
Inspired by: Vadim Goncharov
Diffstat (limited to 'src/dns.h')
-rw-r--r--src/dns.h27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/dns.h b/src/dns.h
index b04aa285f..0b701391b 100644
--- a/src/dns.h
+++ b/src/dns.h
@@ -17,14 +17,27 @@ struct rspamd_dns_reply;
struct config_file;
typedef void (*dns_callback_type) (struct rspamd_dns_reply *reply, gpointer arg);
+
/**
- * Implements DNS server
+ * Represents DNS server
*/
struct rspamd_dns_server {
struct upstream up; /**< upstream structure */
gchar *name; /**< name of DNS server */
+ struct rspamd_dns_io_channel *io_channels;
+ struct rspamd_dns_io_channel *cur_io_channel;
+};
+
+/**
+ * IO channel for a specific DNS server
+ */
+struct rspamd_dns_io_channel {
+ struct rspamd_dns_server *srv;
+ struct rspamd_dns_resolver *resolver;
gint sock; /**< persistent socket */
struct event ev;
+ GHashTable *requests; /**< requests in flight */
+ struct rspamd_dns_io_channel *prev, *next;
};
#define DNS_K_TEA_KEY_SIZE 16
@@ -44,11 +57,11 @@ struct dns_k_permutor {
struct rspamd_dns_resolver {
struct rspamd_dns_server servers[MAX_SERVERS];
gint servers_num; /**< number of DNS servers registered */
- GHashTable *requests; /**< requests in flight */
struct dns_k_permutor *permutor; /**< permutor for randomizing request id */
guint request_timeout;
guint max_retransmits;
guint max_errors;
+ GHashTable *io_channels; /**< hash of io chains indexed by socket */
memory_pool_t *static_pool; /**< permament pool (cfg_pool) */
gboolean throttling; /**< dns servers are busy */
gboolean is_master_slave; /**< if this is true, then select upstreams as master/slave */
@@ -74,7 +87,7 @@ enum rspamd_request_type {
struct rspamd_dns_request {
memory_pool_t *pool; /**< pool associated with request */
struct rspamd_dns_resolver *resolver;
- struct rspamd_dns_server *server;
+ struct rspamd_dns_io_channel *io;
dns_callback_type func;
gpointer arg;
struct event timer_event;
@@ -234,12 +247,12 @@ struct dns_query {
/* Rspamd DNS API */
-/*
+/**
* Init DNS resolver, params are obtained from a config file or system file /etc/resolv.conf
*/
struct rspamd_dns_resolver *dns_resolver_init (struct event_base *ev_base, struct config_file *cfg);
-/*
+/**
* Make a DNS request
* @param resolver resolver object
* @param session async session to register event
@@ -254,12 +267,12 @@ gboolean make_dns_request (struct rspamd_dns_resolver *resolver,
struct rspamd_async_session *session, memory_pool_t *pool, dns_callback_type cb,
gpointer ud, enum rspamd_request_type type, ...);
-/*
+/**
* Get textual presentation of DNS error code
*/
const gchar *dns_strerror (enum dns_rcode rcode);
-/*
+/**
* Get textual presentation of DNS request type
*/
const gchar *dns_strtype (enum rspamd_request_type type);