summaryrefslogtreecommitdiffstats
path: root/src/plugins/regexp.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2009-05-04 18:55:12 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2009-05-04 18:55:12 +0400
commit05556b30f9f309abc532f26c86a2e8266c2e72c7 (patch)
tree70007f830b786030de17e38df04754907094bb81 /src/plugins/regexp.c
parente30ea48c912be20ddc9c327205d146e46d60535e (diff)
downloadrspamd-05556b30f9f309abc532f26c86a2e8266c2e72c7.tar.gz
rspamd-05556b30f9f309abc532f26c86a2e8266c2e72c7.zip
* Add counters for rspamd symbols
* Fix shared hashes
Diffstat (limited to 'src/plugins/regexp.c')
-rw-r--r--src/plugins/regexp.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c
index 12feee911..4eaca581e 100644
--- a/src/plugins/regexp.c
+++ b/src/plugins/regexp.c
@@ -34,6 +34,7 @@
#include "../message.h"
#include "../modules.h"
#include "../cfg_file.h"
+#include "../util.h"
#include "../expressions.h"
#define DEFAULT_STATFILE_PREFIX "./"
@@ -41,6 +42,7 @@
struct regexp_module_item {
struct expression *expr;
char *symbol;
+ long int avg_time;
};
struct autolearn_data {
@@ -501,7 +503,7 @@ process_regexp_expression (struct expression *expr, struct worker_task *task)
else {
msg_warn ("process_regexp_expression: regexp expression seems to be invalid: empty stack at the end of expression");
}
-
+
g_queue_free (stack);
return FALSE;
@@ -510,9 +512,31 @@ process_regexp_expression (struct expression *expr, struct worker_task *task)
static void
process_regexp_item (struct regexp_module_item *item, struct worker_task *task)
{
+ struct timespec ts1, ts2;
+ uint64_t diff;
+
+#ifdef HAVE_CLOCK_PROCESS_CPUTIME_ID
+ clock_gettime (CLOCK_PROCESS_CPUTIME_ID, &ts1);
+#elif defined(HAVE_CLOCK_VIRTUAL)
+ clock_gettime (CLOCK_VIRTUAL, &ts1);
+#else
+ clock_gettime (CLOCK_REALTIME, &ts1);
+#endif
+
if (process_regexp_expression (item->expr, task)) {
insert_result (task, regexp_module_ctx->metric, item->symbol, 1, NULL);
}
+
+#ifdef HAVE_CLOCK_PROCESS_CPUTIME_ID
+ clock_gettime (CLOCK_PROCESS_CPUTIME_ID, &ts2);
+#elif defined(HAVE_CLOCK_VIRTUAL)
+ clock_gettime (CLOCK_VIRTUAL, &ts2);
+#else
+ clock_gettime (CLOCK_REALTIME, &ts2);
+#endif
+
+ diff = (ts2.tv_sec - ts1.tv_sec) * 1000000 + (ts2.tv_nsec - ts1.tv_nsec) / 1000;
+ set_counter (item->symbol, diff);
}
static int