aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2012-12-03 16:30:09 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2012-12-03 16:30:09 +0400
commite981e52b3a4e74fc365150a9e8cac43bc10c2969 (patch)
tree43de51f9e0a621fa016d03ab4a5c8ac81f90a7e5 /src/plugins
parent71defe8523b86a0c0ac898f5512f70ab74df15c7 (diff)
downloadrspamd-e981e52b3a4e74fc365150a9e8cac43bc10c2969.tar.gz
rspamd-e981e52b3a4e74fc365150a9e8cac43bc10c2969.zip
Fix diff normalization.
Fix redirector call in surbl module.
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/surbl.c15
-rw-r--r--src/plugins/surbl.h3
2 files changed, 12 insertions, 6 deletions
diff --git a/src/plugins/surbl.c b/src/plugins/surbl.c
index 18b8441ea..ba2df2dd8 100644
--- a/src/plugins/surbl.c
+++ b/src/plugins/surbl.c
@@ -820,6 +820,7 @@ free_redirector_session (void *ud)
struct redirector_param *param = (struct redirector_param *)ud;
event_del (&param->ev);
+ g_string_free (param->buf, TRUE);
close (param->sock);
}
@@ -828,10 +829,11 @@ redirector_callback (gint fd, short what, void *arg)
{
struct redirector_param *param = (struct redirector_param *)arg;
struct worker_task *task = param->task;
- gchar url_buf[1024];
+ gchar url_buf[512];
gint r;
struct timeval *timeout;
gchar *p, *c;
+ gboolean found = FALSE;
switch (param->state) {
case STATE_CONNECT:
@@ -872,20 +874,22 @@ redirector_callback (gint fd, short what, void *arg)
return;
}
- url_buf[r - 1] = '\0';
+ g_string_append_len (param->buf, url_buf, r);
- if ((p = strstr (url_buf, "Uri: ")) != NULL) {
+ if ((p = strstr (param->buf->str, "Uri: ")) != NULL) {
p += sizeof ("Uri: ") - 1;
c = p;
- while (p++ < url_buf + sizeof (url_buf) - 1) {
+ while (p++ < param->buf->str + param->buf->len - 1) {
if (*p == '\r' || *p == '\n') {
*p = '\0';
+ found = TRUE;
break;
}
}
- if (*p == '\0') {
+ if (found) {
debug_task ("<%s> got reply from redirector: '%s' -> '%s'", param->task->message_id, struri (param->url), c);
parse_uri (param->url, memory_pool_strdup (param->task->task_pool, c), param->task->task_pool);
+ make_surbl_requests (param->url, param->task, param->suffix, FALSE);
}
}
upstream_ok (&param->redirector->up, param->task->tv.tv_sec);
@@ -934,6 +938,7 @@ register_redirector_call (struct uri *url, struct worker_task *task,
param->sock = s;
param->suffix = suffix;
param->redirector = selected;
+ param->buf = g_string_sized_new (1024);
timeout = memory_pool_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;
diff --git a/src/plugins/surbl.h b/src/plugins/surbl.h
index 49b79ea8f..950e55bcb 100644
--- a/src/plugins/surbl.h
+++ b/src/plugins/surbl.h
@@ -68,8 +68,9 @@ struct redirector_param {
struct redirector_upstream *redirector;
enum {
STATE_CONNECT,
- STATE_READ,
+ STATE_READ
} state;
+ GString *buf;
struct event ev;
gint sock;
GTree *tree;