aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2009-01-16 17:02:26 +0300
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2009-01-16 17:02:26 +0300
commitfe5ad5874aad220fb12a259e607f89ce5fae7465 (patch)
treee22215da4087e82926bf3797469a4e00914e8c1e /src
parentd0681272065a04de5e8249b782ac7f9efa938555 (diff)
downloadrspamd-fe5ad5874aad220fb12a259e607f89ce5fae7465.tar.gz
rspamd-fe5ad5874aad220fb12a259e607f89ce5fae7465.zip
* Add simple utility for sending mail to rspamd
* Fix some errors in freeing message object
Diffstat (limited to 'src')
-rw-r--r--src/filter.c2
-rw-r--r--src/fstring.c1
-rw-r--r--src/protocol.c32
-rw-r--r--src/statfile.c3
-rw-r--r--src/worker.c7
5 files changed, 24 insertions, 21 deletions
diff --git a/src/filter.c b/src/filter.c
index 290769c54..443784ad6 100644
--- a/src/filter.c
+++ b/src/filter.c
@@ -381,6 +381,8 @@ statfiles_callback (gpointer key, gpointer value, void *arg)
}
weight = st->classifier->classify_func (task->worker->srv->statfile_pool, filename, tokens);
+
+ msg_debug ("process_statfiles: got classify weight: %.2f", weight);
if (weight > 0.000001) {
if ((w = g_hash_table_lookup (data->metrics, st->metric)) == NULL) {
diff --git a/src/fstring.c b/src/fstring.c
index cad7c8710..2935fe8e6 100644
--- a/src/fstring.c
+++ b/src/fstring.c
@@ -188,6 +188,7 @@ fstralloc (memory_pool_t *pool, size_t len)
}
res->size = len;
+ res->len = 0;
return res;
}
diff --git a/src/protocol.c b/src/protocol.c
index 027e3a91a..0fb7764c0 100644
--- a/src/protocol.c
+++ b/src/protocol.c
@@ -73,7 +73,7 @@ parse_command (struct worker_task *task, char *line)
token = strsep (&line, " ");
if (line == NULL || token == NULL) {
- msg_debug ("parse_command: bad comand: %s", token);
+ msg_debug ("parse_command: bad command: %s", token);
return -1;
}
@@ -85,7 +85,7 @@ parse_command (struct worker_task *task, char *line)
task->cmd = CMD_CHECK;
}
else {
- msg_debug ("parse_command: bad comand: %s", token);
+ msg_debug ("parse_command: bad command: %s", token);
return -1;
}
break;
@@ -99,7 +99,7 @@ parse_command (struct worker_task *task, char *line)
task->cmd = CMD_SKIP;
}
else {
- msg_debug ("parse_command: bad comand: %s", token);
+ msg_debug ("parse_command: bad command: %s", token);
return -1;
}
break;
@@ -113,7 +113,7 @@ parse_command (struct worker_task *task, char *line)
task->cmd = CMD_PROCESS;
}
else {
- msg_debug ("parse_command: bad comand: %s", token);
+ msg_debug ("parse_command: bad command: %s", token);
return -1;
}
break;
@@ -127,12 +127,12 @@ parse_command (struct worker_task *task, char *line)
task->cmd = CMD_REPORT_IFSPAM;
}
else {
- msg_debug ("parse_command: bad comand: %s", token);
+ msg_debug ("parse_command: bad command: %s", token);
return -1;
}
break;
default:
- msg_debug ("parse_command: bad comand: %s", token);
+ msg_debug ("parse_command: bad command: %s", token);
return -1;
}
@@ -187,12 +187,16 @@ parse_header (struct worker_task *task, char *line)
case 'C':
/* content-length */
if (strncasecmp (headern, CONTENT_LENGTH_HEADER, sizeof (CONTENT_LENGTH_HEADER) - 1) == 0) {
- task->content_length = strtoul (line, &err, 10);
- task->msg = memory_pool_alloc (task->task_pool, sizeof (f_str_buf_t));
- task->msg->buf = fstralloc (task->task_pool, task->content_length);
- if (task->msg->buf == NULL) {
- msg_err ("read_socket: cannot allocate memory for message buffer");
- return -1;
+ if (task->content_length == 0) {
+ task->content_length = strtoul (line, &err, 10);
+ task->msg = memory_pool_alloc0 (task->task_pool, sizeof (f_str_buf_t));
+ task->msg->buf = fstralloc (task->task_pool, task->content_length);
+ if (task->msg->buf == NULL) {
+ msg_err ("read_socket: cannot allocate memory for message buffer");
+ return -1;
+ }
+ task->msg->pos = task->msg->buf->begin;
+ update_buf_size (task->msg);
}
}
else {
@@ -306,13 +310,13 @@ show_url_header (struct worker_task *task)
if (TAILQ_NEXT (url, next) != NULL) {
c = *(host.begin + host.len);
*(host.begin + host.len) = '\0';
- r += snprintf (outbuf, sizeof (outbuf) - r, "%s, ", host.begin);
+ r += snprintf (outbuf + r, sizeof (outbuf) - r, "%s, ", host.begin);
*(host.begin + host.len) = c;
}
else {
c = *(host.begin + host.len);
*(host.begin + host.len) = '\0';
- r += snprintf (outbuf, sizeof (outbuf) - r, "%s" CRLF, host.begin);
+ r += snprintf (outbuf + r, sizeof (outbuf) - r, "%s" CRLF, host.begin);
*(host.begin + host.len) = c;
}
}
diff --git a/src/statfile.c b/src/statfile.c
index ca78b79e9..c0a2a2487 100644
--- a/src/statfile.c
+++ b/src/statfile.c
@@ -295,9 +295,7 @@ statfile_pool_get_block (statfile_pool_t *pool, char *filename, uint32_t h1, uin
if (i + blocknum > file->blocks) {
break;
}
- msg_debug ("statfile_pool_get_block: test block with h1=%u, h2=%u, number %u in chain %u", block->hash1, block->hash2, i, blocknum);
if (block->hash1 == h1 && block->hash2 == h2) {
- msg_debug ("statfile_pool_get_block: found block with h1=%u, h2=%u, number %u in chain %u", h1, h2, i, blocknum);
block->last_access = now - (time_t)header->create_time;
return block->value;
}
@@ -305,7 +303,6 @@ statfile_pool_get_block (statfile_pool_t *pool, char *filename, uint32_t h1, uin
block = (struct stat_file_block *)c;
}
- msg_debug ("statfile_pool_get_block: block with h1=%u, h2=%u, not found in chain %u", h1, h2, blocknum);
return 0;
}
diff --git a/src/worker.c b/src/worker.c
index bcbea640e..4a6f9acdd 100644
--- a/src/worker.c
+++ b/src/worker.c
@@ -87,8 +87,7 @@ free_task (struct worker_task *task)
}
while (!TAILQ_EMPTY (&task->parts)) {
part = TAILQ_FIRST (&task->parts);
- g_object_unref (part->type);
- g_object_unref (part->content);
+ g_byte_array_free (part->content, FALSE);
TAILQ_REMOVE (&task->parts, part, next);
}
memory_pool_delete (task->task_pool);
@@ -222,6 +221,7 @@ read_socket (struct bufferevent *bev, void *arg)
r = bufferevent_read (bev, task->msg->pos, task->msg->free);
if (r > 0) {
task->msg->pos += r;
+ msg_debug ("read_socket: read %zd bytes from socket, %zd bytes left", r, task->msg->free);
update_buf_size (task->msg);
if (task->msg->free == 0) {
r = process_message (task);
@@ -244,9 +244,8 @@ read_socket (struct bufferevent *bev, void *arg)
}
}
else {
- msg_err ("read_socket: cannot read data to buffer: %ld", (long int)r);
+ msg_warn ("read_socket: cannot read data to buffer (free space: %zd): %ld", task->msg->free, (long int)r);
bufferevent_disable (bev, EV_READ);
- bufferevent_free (bev);
free_task (task);
}
break;