diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-10-05 17:58:04 +0400 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-10-05 17:58:04 +0400 |
commit | 876e5f104227f855269daa0c2812f26a45b38cc7 (patch) | |
tree | 68f4f9a405f8613a809c56b08d2253354e548dec /src | |
parent | ce482fbf8e2c1b9bf0cdba0ab61bc26985ee8977 (diff) | |
download | rspamd-876e5f104227f855269daa0c2812f26a45b38cc7.tar.gz rspamd-876e5f104227f855269daa0c2812f26a45b38cc7.zip |
* Add once_received plugin (by dmx)
* Fix read_callback to avoid double freeing of task object
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/lua/once_received.lua | 15 | ||||
-rw-r--r-- | src/worker.c | 11 |
2 files changed, 20 insertions, 6 deletions
diff --git a/src/plugins/lua/once_received.lua b/src/plugins/lua/once_received.lua new file mode 100644 index 000000000..409ec4aff --- /dev/null +++ b/src/plugins/lua/once_received.lua @@ -0,0 +1,15 @@ +-- 0 or 1 received: = spam + +local metric = 'default' +local symbol = 'ONCE_RECEIVED' + +function check_quantity_received (task) + local recvh = task:get_received_headers() + if table.maxn(recvh) <= 1 then + task:insert_result(metric, symbol, 1) + end +end + +-- Register symbol's callback +local m = rspamd_config:get_metric(metric) +m:register_symbol(symbol, 1.0, 'check_quantity_received') diff --git a/src/worker.c b/src/worker.c index 880da71ab..e246f3213 100644 --- a/src/worker.c +++ b/src/worker.c @@ -174,7 +174,7 @@ read_socket (f_str_t * in, void *arg) task->state = WRITE_ERROR; } if (task->state == WRITE_REPLY || task->state == WRITE_ERROR) { - write_socket (task); + return write_socket (task); } break; case READ_MESSAGE: @@ -188,20 +188,19 @@ read_socket (f_str_t * in, void *arg) task->last_error = "MIME processing error"; task->error_code = RSPAMD_FILTER_ERROR; task->state = WRITE_ERROR; - write_socket (task); + return write_socket (task); } if (task->cmd == CMD_OTHER) { /* Skip filters */ task->state = WRITE_REPLY; - write_socket (task); - return TRUE; + return write_socket (task); } r = process_filters (task); if (r == -1) { task->last_error = "Filter processing error"; task->error_code = RSPAMD_FILTER_ERROR; task->state = WRITE_ERROR; - write_socket (task); + return write_socket (task); } else if (r == 0) { task->state = WAIT_FILTER; @@ -209,7 +208,7 @@ read_socket (f_str_t * in, void *arg) } else { process_statfiles (task); - write_socket (task); + return write_socket (task); } break; default: |