]> source.dussan.org Git - rspamd.git/commitdiff
* Add once_received plugin (by dmx)
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Mon, 5 Oct 2009 13:58:04 +0000 (17:58 +0400)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Mon, 5 Oct 2009 13:58:04 +0000 (17:58 +0400)
* Fix read_callback to avoid double freeing of task object

src/plugins/lua/once_received.lua [new file with mode: 0644]
src/worker.c

diff --git a/src/plugins/lua/once_received.lua b/src/plugins/lua/once_received.lua
new file mode 100644 (file)
index 0000000..409ec4a
--- /dev/null
@@ -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')
index 880da71ab221ce5d451441c89f7d57361c22e3df..e246f321372ab041d94fef2bdaddceb301da0395 100644 (file)
@@ -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: