From f15cf65c6ae417e7744492b3e3961749637b123d Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 11 Nov 2014 17:27:14 +0000 Subject: [PATCH] Fix timeouts in redirector. --- src/plugins/surbl.c | 9 ++------- src/plugins/surbl.h | 8 ++++---- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/plugins/surbl.c b/src/plugins/surbl.c index 931eb844c..8e4c41205 100644 --- a/src/plugins/surbl.c +++ b/src/plugins/surbl.c @@ -879,10 +879,7 @@ redirector_callback (gint fd, short what, void *arg) timeout = rspamd_mempool_alloc (param->task->task_pool, sizeof (struct timeval)); - timeout->tv_sec = surbl_module_ctx->read_timeout / 1000; - timeout->tv_usec = - (surbl_module_ctx->read_timeout - timeout->tv_sec * - 1000) * 1000; + double_to_tv (surbl_module_ctx->read_timeout, timeout); event_del (¶m->ev); event_set (¶m->ev, param->sock, @@ -1021,9 +1018,7 @@ register_redirector_call (struct uri *url, struct rspamd_task *task, param->buf = g_string_sized_new (1024); param->tree = tree; timeout = rspamd_mempool_alloc (task->task_pool, sizeof (struct timeval)); - timeout->tv_sec = surbl_module_ctx->connect_timeout / 1000; - timeout->tv_usec = - (surbl_module_ctx->connect_timeout - timeout->tv_sec * 1000) * 1000; + double_to_tv (surbl_module_ctx->connect_timeout, timeout); event_set (¶m->ev, s, EV_WRITE, redirector_callback, (void *)param); event_add (¶m->ev, timeout); register_async_event (task->s, diff --git a/src/plugins/surbl.h b/src/plugins/surbl.h index a224e895a..7701c8304 100644 --- a/src/plugins/surbl.h +++ b/src/plugins/surbl.h @@ -7,8 +7,8 @@ #define DEFAULT_REDIRECTOR_PORT 8080 #define DEFAULT_SURBL_WEIGHT 10 -#define DEFAULT_REDIRECTOR_CONNECT_TIMEOUT 1000 -#define DEFAULT_REDIRECTOR_READ_TIMEOUT 5000 +#define DEFAULT_REDIRECTOR_CONNECT_TIMEOUT 1.0 +#define DEFAULT_REDIRECTOR_READ_TIMEOUT 5.0 #define DEFAULT_SURBL_MAX_URLS 1000 #define DEFAULT_SURBL_URL_EXPIRE 86400 #define DEFAULT_SURBL_SYMBOL "SURBL_DNS" @@ -19,8 +19,8 @@ struct surbl_ctx { gint (*filter)(struct rspamd_task *task); guint16 weight; - guint connect_timeout; - guint read_timeout; + gdouble connect_timeout; + gdouble read_timeout; guint max_urls; guint url_expire; GList *suffixes; -- 2.39.5