]> source.dussan.org Git - rspamd.git/commitdiff
Fix timeouts in redirector.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 11 Nov 2014 17:27:14 +0000 (17:27 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 11 Nov 2014 17:27:14 +0000 (17:27 +0000)
src/plugins/surbl.c
src/plugins/surbl.h

index 931eb844c07728e89afa4a444cfabf33b3519488..8e4c41205228d92d9e0dcec6b57432418a7bb4cd 100644 (file)
@@ -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 (&param->ev);
                        event_set (&param->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 (&param->ev, s, EV_WRITE, redirector_callback, (void *)param);
        event_add (&param->ev, timeout);
        register_async_event (task->s,
index a224e895ac6f77b0400de55b387759a3d0795bb1..7701c8304cd7ac44e48bf574a8a18b60cf8e6f49 100644 (file)
@@ -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;