t = b1;
/* The first string */
- while (r1 > 0 && h - b1 < (gint)sizeof (b1)) {
+ while (r1 > 0 && t - b1 < (gint)sizeof (b1)) {
if (!g_ascii_isspace (*h)) {
*t++ = g_ascii_tolower (*h);
}
}
t1.begin = b1;
- t1.len = h - b1;
+ t1.len = t - b1;
/* The second string */
h = p2;
t = b2;
- while (r2 > 0 && h - b2 < (gint)sizeof (b2)) {
+ while (r2 > 0 && t - b2 < (gint)sizeof (b2)) {
if (!g_ascii_isspace (*h)) {
*t++ = g_ascii_tolower (*h);
}
}
t2.begin = b2;
- t2.len = h - b2;
+ t2.len = t - b2;
cur_diff += compare_diff_distance_unnormalized (&t1, &t2);
}
struct redirector_param *param = (struct redirector_param *)ud;
event_del (¶m->ev);
+ g_string_free (param->buf, TRUE);
close (param->sock);
}
{
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:
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 (¶m->redirector->up, param->task->tv.tv_sec);
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;