]> source.dussan.org Git - rspamd.git/commitdiff
* Enable counters interface
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Tue, 5 May 2009 12:57:11 +0000 (16:57 +0400)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Tue, 5 May 2009 12:57:11 +0000 (16:57 +0400)
* Move modules configuration to init stage

src/main.c
src/plugins/regexp.c
src/util.c
src/worker.c

index 668c0d7cc6e30b7b668001f4c63f04076e6b27cc..d64884924887aaff5f6a73d3a83a3ae04f364e54 100644 (file)
@@ -465,6 +465,8 @@ main (int argc, char **argv, char **env)
        }
 
        fclose (f);
+       /* Init counters */
+       counters = rspamd_hash_new_shared (rspamd->server_pool, g_str_hash, g_str_equal, 64);
 
        /* Init C modules */
        for (i = 0; i < MODULES_NUM; i ++) {
@@ -491,6 +493,7 @@ main (int argc, char **argv, char **env)
                return res ? EXIT_SUCCESS : EXIT_FAILURE;
        }
 
+
        /* Create listen socket */
        listen_sock = create_listen_socket (&rspamd->cfg->bind_addr, rspamd->cfg->bind_port, 
                                                                                rspamd->cfg->bind_family, rspamd->cfg->bind_host);
@@ -574,8 +577,11 @@ main (int argc, char **argv, char **env)
        /* Init statfile pool */
        rspamd->statfile_pool = statfile_pool_new (cfg->max_statfile_size);
 
-       /* Init counters */
-       counters = rspamd_hash_new_shared (rspamd->server_pool, g_str_hash, g_str_equal, 64);
+
+       /* Perform modules configuring */
+       for (i = 0; i < MODULES_NUM; i ++) {
+               modules[i].module_config_func (cfg);
+       }
        
        for (i = 0; i < cfg->workers_number; i++) {
                fork_worker (rspamd, listen_sock, TYPE_WORKER);
index 4eaca581e2e974147167e9d355e78c3ddf03c624..8efc013dcdec4d4fa0f9b2ac0a48b161c795197e 100644 (file)
@@ -185,6 +185,7 @@ regexp_module_config (struct config_file *cfg)
                        if (!read_regexp_expression (regexp_module_ctx->regexp_pool, cur_item, cur->param, cur->value, cfg)) {
                                res = FALSE;
                        }
+                       set_counter (cur_item->symbol, 0);
                        regexp_module_ctx->items = g_list_prepend (regexp_module_ctx->items, cur_item);
                }
        }
index 93774a9aed287ad0efd4e6f2a4d8d984bbc45a15..eb57d6c884244736477cd882cc5f8c8cfe1401ca 100644 (file)
@@ -819,13 +819,12 @@ set_counter (const char *name, long int value)
        double alpha;
        char *key;
        
-#if 0
        cd = rspamd_hash_lookup (counters, (gpointer)name);
 
        if (cd == NULL) {
                cd = memory_pool_alloc_shared (counters->pool, sizeof (struct counter_data));
                cd->value = value;
-               cd->number = 1;
+               cd->number = 0;
                key = memory_pool_strdup_shared (counters->pool, name);
                rspamd_hash_insert (counters, (gpointer)key, (gpointer)cd);
        }
@@ -838,7 +837,6 @@ set_counter (const char *name, long int value)
 
                memory_pool_wunlock_rwlock (counters->lock);
        }
-#endif
 }
 
 /*
index e97454121d9644fac6cc003debc9d021fc5080ea..263d1eb934b5ebcbba23d56979088677e930e783 100644 (file)
@@ -309,7 +309,6 @@ void
 start_worker (struct rspamd_worker *worker, int listen_sock)
 {
        struct sigaction signals;
-       int i;
 
 #ifdef WITH_PROFILER
        extern void _start (void), etext (void);
@@ -356,11 +355,6 @@ start_worker (struct rspamd_worker *worker, int listen_sock)
        event_set(&worker->bind_ev, listen_sock, EV_READ | EV_PERSIST, accept_socket, (void *)worker);
        event_add(&worker->bind_ev, NULL);
 
-       /* Perform modules configuring */
-       for (i = 0; i < MODULES_NUM; i ++) {
-               modules[i].module_config_func (worker->srv->cfg);
-       }
-
        /* Send SIGUSR2 to parent */
        kill (getppid (), SIGUSR2);