#endif
#define YYDEBUG 1
-extern struct config_file *cfg;
+extern struct config_file *yacc_cfg;
extern int yylineno;
extern char *yytext;
yyerror ("yyparse: \"%s\" is not a directory", $3);
YYERROR;
}
- cfg->temp_dir = memory_pool_strdup (cfg->cfg_pool, $3);
+ yacc_cfg->temp_dir = memory_pool_strdup (yacc_cfg->cfg_pool, $3);
free ($3);
}
;
pidfile :
PIDFILE EQSIGN QUOTEDSTRING {
- if (cfg->pid_file == NULL) {
+ if (yacc_cfg->pid_file == NULL) {
/* Allow override this value from command line */
- cfg->pid_file = $3;
+ yacc_cfg->pid_file = $3;
}
}
;
filters:
FILTERS EQSIGN QUOTEDSTRING {
- cfg->filters_str = memory_pool_strdup (cfg->cfg_pool, $3);
+ yacc_cfg->filters_str = memory_pool_strdup (yacc_cfg->cfg_pool, $3);
free ($3);
}
;
memcached_params:
memcached_hosts {
- if (!add_memcached_server (cfg, $1)) {
+ if (!add_memcached_server (yacc_cfg, $1)) {
yyerror ("yyparse: add_memcached_server");
YYERROR;
}
;
memcached_error_time:
ERROR_TIME EQSIGN NUMBER {
- cfg->memcached_error_time = $3;
+ yacc_cfg->memcached_error_time = $3;
}
;
memcached_dead_time:
DEAD_TIME EQSIGN NUMBER {
- cfg->memcached_dead_time = $3;
+ yacc_cfg->memcached_dead_time = $3;
}
;
memcached_maxerrors:
MAXERRORS EQSIGN NUMBER {
- cfg->memcached_maxerrors = $3;
+ yacc_cfg->memcached_maxerrors = $3;
}
;
memcached_connect_timeout:
CONNECT_TIMEOUT EQSIGN SECONDS {
- cfg->memcached_connect_timeout = $3;
+ yacc_cfg->memcached_connect_timeout = $3;
}
;
memcached_protocol:
PROTOCOL EQSIGN STRING {
if (strncasecmp ($3, "udp", sizeof ("udp") - 1) == 0) {
- cfg->memcached_protocol = UDP_TEXT;
+ yacc_cfg->memcached_protocol = UDP_TEXT;
}
else if (strncasecmp ($3, "tcp", sizeof ("tcp") - 1) == 0) {
- cfg->memcached_protocol = TCP_TEXT;
+ yacc_cfg->memcached_protocol = TCP_TEXT;
}
else {
yyerror ("yyparse: cannot recognize protocol: %s", $3);
/* Workers section */
worker:
WORKER OBRACE workerbody EBRACE {
- cfg->workers = g_list_prepend (cfg->workers, cur_worker);
+ yacc_cfg->workers = g_list_prepend (yacc_cfg->workers, cur_worker);
cur_worker = NULL;
}
;
bindsock:
BINDSOCK EQSIGN bind_cred {
- cur_worker = check_worker_conf (cfg, cur_worker);
+ cur_worker = check_worker_conf (yacc_cfg, cur_worker);
- if (!parse_bind_line (cfg, cur_worker, $3)) {
+ if (!parse_bind_line (yacc_cfg, cur_worker, $3)) {
yyerror ("yyparse: parse_bind_line");
YYERROR;
}
workertype:
TYPE EQSIGN QUOTEDSTRING {
- cur_worker = check_worker_conf (cfg, cur_worker);
+ cur_worker = check_worker_conf (yacc_cfg, cur_worker);
if (g_ascii_strcasecmp ($3, "normal") == 0) {
cur_worker->type = TYPE_WORKER;
cur_worker->has_socket = TRUE;
workercount:
COUNT EQSIGN NUMBER {
- cur_worker = check_worker_conf (cfg, cur_worker);
+ cur_worker = check_worker_conf (yacc_cfg, cur_worker);
if ($3 > 0) {
cur_worker->count = $3;
workerlimitfiles:
MAXFILES EQSIGN NUMBER {
- cur_worker = check_worker_conf (cfg, cur_worker);
+ cur_worker = check_worker_conf (yacc_cfg, cur_worker);
cur_worker->rlimit_nofile = $3;
}
;
workerlimitcore:
MAXCORE EQSIGN NUMBER {
- cur_worker = check_worker_conf (cfg, cur_worker);
+ cur_worker = check_worker_conf (yacc_cfg, cur_worker);
cur_worker->rlimit_maxcore = $3;
}
;
workerparam:
STRING EQSIGN QUOTEDSTRING {
- cur_worker = check_worker_conf (cfg, cur_worker);
+ cur_worker = check_worker_conf (yacc_cfg, cur_worker);
g_hash_table_insert (cur_worker->params, $1, $3);
}
if (cur_metric->classifier == NULL) {
cur_metric->classifier = get_classifier ("winnow");
}
- g_hash_table_insert (cfg->metrics, cur_metric->name, cur_metric);
- cfg->metrics_list = g_list_prepend (cfg->metrics_list, cur_metric);
+ g_hash_table_insert (yacc_cfg->metrics, cur_metric->name, cur_metric);
+ yacc_cfg->metrics_list = g_list_prepend (yacc_cfg->metrics_list, cur_metric);
cur_metric = NULL;
}
;
metricname:
NAME EQSIGN QUOTEDSTRING {
if (cur_metric == NULL) {
- cur_metric = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct metric));
+ cur_metric = memory_pool_alloc0 (yacc_cfg->cfg_pool, sizeof (struct metric));
}
- cur_metric->name = memory_pool_strdup (cfg->cfg_pool, $3);
+ cur_metric->name = memory_pool_strdup (yacc_cfg->cfg_pool, $3);
}
;
metricfunction:
FUNCTION EQSIGN QUOTEDSTRING {
if (cur_metric == NULL) {
- cur_metric = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct metric));
+ cur_metric = memory_pool_alloc0 (yacc_cfg->cfg_pool, sizeof (struct metric));
}
- cur_metric->func_name = memory_pool_strdup (cfg->cfg_pool, $3);
+ cur_metric->func_name = memory_pool_strdup (yacc_cfg->cfg_pool, $3);
#ifdef WITH_LUA
cur_metric->func = lua_consolidation_func;
#elif !defined(WITHOUT_PERL)
metricscore:
REQUIRED_SCORE EQSIGN NUMBER {
if (cur_metric == NULL) {
- cur_metric = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct metric));
+ cur_metric = memory_pool_alloc0 (yacc_cfg->cfg_pool, sizeof (struct metric));
}
cur_metric->required_score = $3;
}
| REQUIRED_SCORE EQSIGN FRACT {
if (cur_metric == NULL) {
- cur_metric = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct metric));
+ cur_metric = memory_pool_alloc0 (yacc_cfg->cfg_pool, sizeof (struct metric));
}
cur_metric->required_score = $3;
}
metricrjscore:
REJECT_SCORE EQSIGN NUMBER {
if (cur_metric == NULL) {
- cur_metric = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct metric));
+ cur_metric = memory_pool_alloc0 (yacc_cfg->cfg_pool, sizeof (struct metric));
}
cur_metric->reject_score = $3;
}
| REJECT_SCORE EQSIGN FRACT {
if (cur_metric == NULL) {
- cur_metric = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct metric));
+ cur_metric = memory_pool_alloc0 (yacc_cfg->cfg_pool, sizeof (struct metric));
}
cur_metric->reject_score = $3;
}
metriccache:
CACHE_FILE EQSIGN QUOTEDSTRING {
if (cur_metric == NULL) {
- cur_metric = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct metric));
+ cur_metric = memory_pool_alloc0 (yacc_cfg->cfg_pool, sizeof (struct metric));
}
- cur_metric->cache_filename = memory_pool_strdup (cfg->cfg_pool, $3);
+ cur_metric->cache_filename = memory_pool_strdup (yacc_cfg->cfg_pool, $3);
}
;
factorparam:
QUOTEDSTRING EQSIGN FRACT {
- double *tmp = memory_pool_alloc (cfg->cfg_pool, sizeof (double));
+ double *tmp = memory_pool_alloc (yacc_cfg->cfg_pool, sizeof (double));
*tmp = $3;
- g_hash_table_insert (cfg->factors, $1, tmp);
+ g_hash_table_insert (yacc_cfg->factors, $1, tmp);
}
| QUOTEDSTRING EQSIGN NUMBER {
- double *tmp = memory_pool_alloc (cfg->cfg_pool, sizeof (double));
+ double *tmp = memory_pool_alloc (yacc_cfg->cfg_pool, sizeof (double));
*tmp = $3;
- g_hash_table_insert (cfg->factors, $1, tmp);
+ g_hash_table_insert (yacc_cfg->factors, $1, tmp);
}
| GROW_FACTOR EQSIGN FRACT {
- cfg->grow_factor = $3;
+ yacc_cfg->grow_factor = $3;
}
| GROW_FACTOR EQSIGN NUMBER {
- cfg->grow_factor = $3;
+ yacc_cfg->grow_factor = $3;
}
modules:
if (glob(pattern, GLOB_DOOFFS, NULL, &globbuf) == 0) {
for (i = 0; i < globbuf.gl_pathc; i ++) {
- cur = memory_pool_alloc (cfg->cfg_pool, sizeof (struct script_module));
+ cur = memory_pool_alloc (yacc_cfg->cfg_pool, sizeof (struct script_module));
if (cur == NULL) {
yyerror ("yyparse: g_malloc: %s", strerror(errno));
YYERROR;
}
- cur->path = memory_pool_strdup (cfg->cfg_pool, globbuf.gl_pathv[i]);
- cfg->script_modules = g_list_prepend (cfg->script_modules, cur);
+ cur->path = memory_pool_strdup (yacc_cfg->cfg_pool, globbuf.gl_pathv[i]);
+ yacc_cfg->script_modules = g_list_prepend (yacc_cfg->script_modules, cur);
}
globfree (&globbuf);
}
compositescmd:
PARAM EQSIGN QUOTEDSTRING {
struct expression *expr;
- if ((expr = parse_expression (cfg->cfg_pool, $3)) == NULL) {
+ if ((expr = parse_expression (yacc_cfg->cfg_pool, $3)) == NULL) {
yyerror ("yyparse: cannot parse composite expression: %s", $3);
YYERROR;
}
- g_hash_table_insert (cfg->composite_symbols, $1, expr);
+ g_hash_table_insert (yacc_cfg->composite_symbols, $1, expr);
}
;
module_opt:
MODULE_OPT OBRACE moduleoptbody EBRACE {
- g_hash_table_insert (cfg->modules_opts, $1, cur_module_opt);
+ g_hash_table_insert (yacc_cfg->modules_opts, $1, cur_module_opt);
cur_module_opt = NULL;
}
;
optcmd:
PARAM EQSIGN QUOTEDSTRING {
struct module_opt *mopt;
- mopt = memory_pool_alloc (cfg->cfg_pool, sizeof (struct module_opt));
+ mopt = memory_pool_alloc (yacc_cfg->cfg_pool, sizeof (struct module_opt));
mopt->param = $1;
mopt->value = $3;
cur_module_opt = g_list_prepend (cur_module_opt, mopt);
}
| VARIABLE EQSIGN QUOTEDSTRING {
- g_hash_table_insert (cfg->variables, $1, $3);
+ g_hash_table_insert (yacc_cfg->variables, $1, $3);
}
;
variable:
VARIABLE EQSIGN QUOTEDSTRING {
- g_hash_table_insert (cfg->variables, $1, $3);
+ g_hash_table_insert (yacc_cfg->variables, $1, $3);
}
;
loggingtype:
LOG_TYPE EQSIGN LOG_TYPE_CONSOLE {
- cfg->log_type = RSPAMD_LOG_CONSOLE;
+ yacc_cfg->log_type = RSPAMD_LOG_CONSOLE;
}
| LOG_TYPE EQSIGN LOG_TYPE_SYSLOG {
- cfg->log_type = RSPAMD_LOG_SYSLOG;
+ yacc_cfg->log_type = RSPAMD_LOG_SYSLOG;
}
| LOG_TYPE EQSIGN LOG_TYPE_FILE {
- cfg->log_type = RSPAMD_LOG_FILE;
+ yacc_cfg->log_type = RSPAMD_LOG_FILE;
}
;
logginglevel:
LOG_LEVEL EQSIGN LOG_LEVEL_DEBUG {
- cfg->log_level = G_LOG_LEVEL_DEBUG;
+ yacc_cfg->log_level = G_LOG_LEVEL_DEBUG;
}
| LOG_LEVEL EQSIGN LOG_LEVEL_INFO {
- cfg->log_level = G_LOG_LEVEL_INFO | G_LOG_LEVEL_MESSAGE;
+ yacc_cfg->log_level = G_LOG_LEVEL_INFO | G_LOG_LEVEL_MESSAGE;
}
| LOG_LEVEL EQSIGN LOG_LEVEL_WARNING {
- cfg->log_level = G_LOG_LEVEL_WARNING;
+ yacc_cfg->log_level = G_LOG_LEVEL_WARNING;
}
| LOG_LEVEL EQSIGN LOG_LEVEL_ERROR {
- cfg->log_level = G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL;
+ yacc_cfg->log_level = G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL;
}
;
loggingfacility:
LOG_FACILITY EQSIGN QUOTEDSTRING {
if (strncasecmp ($3, "LOG_AUTH", sizeof ("LOG_AUTH") - 1) == 0) {
- cfg->log_facility = LOG_AUTH;
+ yacc_cfg->log_facility = LOG_AUTH;
}
else if (strncasecmp ($3, "LOG_CRON", sizeof ("LOG_CRON") - 1) == 0) {
- cfg->log_facility = LOG_CRON;
+ yacc_cfg->log_facility = LOG_CRON;
}
else if (strncasecmp ($3, "LOG_DAEMON", sizeof ("LOG_DAEMON") - 1) == 0) {
- cfg->log_facility = LOG_DAEMON;
+ yacc_cfg->log_facility = LOG_DAEMON;
}
else if (strncasecmp ($3, "LOG_MAIL", sizeof ("LOG_MAIL") - 1) == 0) {
- cfg->log_facility = LOG_MAIL;
+ yacc_cfg->log_facility = LOG_MAIL;
}
else if (strncasecmp ($3, "LOG_USER", sizeof ("LOG_USER") - 1) == 0) {
- cfg->log_facility = LOG_USER;
+ yacc_cfg->log_facility = LOG_USER;
}
else if (strncasecmp ($3, "LOG_LOCAL0", sizeof ("LOG_LOCAL0") - 1) == 0) {
- cfg->log_facility = LOG_LOCAL0;
+ yacc_cfg->log_facility = LOG_LOCAL0;
}
else if (strncasecmp ($3, "LOG_LOCAL1", sizeof ("LOG_LOCAL1") - 1) == 0) {
- cfg->log_facility = LOG_LOCAL1;
+ yacc_cfg->log_facility = LOG_LOCAL1;
}
else if (strncasecmp ($3, "LOG_LOCAL2", sizeof ("LOG_LOCAL2") - 1) == 0) {
- cfg->log_facility = LOG_LOCAL2;
+ yacc_cfg->log_facility = LOG_LOCAL2;
}
else if (strncasecmp ($3, "LOG_LOCAL3", sizeof ("LOG_LOCAL3") - 1) == 0) {
- cfg->log_facility = LOG_LOCAL3;
+ yacc_cfg->log_facility = LOG_LOCAL3;
}
else if (strncasecmp ($3, "LOG_LOCAL4", sizeof ("LOG_LOCAL4") - 1) == 0) {
- cfg->log_facility = LOG_LOCAL4;
+ yacc_cfg->log_facility = LOG_LOCAL4;
}
else if (strncasecmp ($3, "LOG_LOCAL5", sizeof ("LOG_LOCAL5") - 1) == 0) {
- cfg->log_facility = LOG_LOCAL5;
+ yacc_cfg->log_facility = LOG_LOCAL5;
}
else if (strncasecmp ($3, "LOG_LOCAL6", sizeof ("LOG_LOCAL6") - 1) == 0) {
- cfg->log_facility = LOG_LOCAL6;
+ yacc_cfg->log_facility = LOG_LOCAL6;
}
else if (strncasecmp ($3, "LOG_LOCAL7", sizeof ("LOG_LOCAL7") - 1) == 0) {
- cfg->log_facility = LOG_LOCAL7;
+ yacc_cfg->log_facility = LOG_LOCAL7;
}
else {
yyerror ("yyparse: invalid logging facility: %s", $3);
loggingfile:
LOG_FILENAME EQSIGN QUOTEDSTRING {
- cfg->log_file = memory_pool_strdup (cfg->cfg_pool, $3);
+ yacc_cfg->log_file = memory_pool_strdup (yacc_cfg->cfg_pool, $3);
free ($3);
}
loggingurls:
LOG_URLS EQSIGN FLAG {
if ($3 != 0) {
- cfg->log_urls = TRUE;
+ yacc_cfg->log_urls = TRUE;
}
}
;
loggingbuffer:
LOG_BUFFER EQSIGN NUMBER
| LOG_BUFFER EQSIGN SIZELIMIT {
- cfg->log_buf_size = $3;
- cfg->log_buffered = TRUE;
+ yacc_cfg->log_buf_size = $3;
+ yacc_cfg->log_buffered = TRUE;
}
;
loggingdebugip:
DEBUG_IP EQSIGN QUOTEDSTRING {
- cfg->debug_ip_map = $3;
+ yacc_cfg->debug_ip_map = $3;
}
;
cur_classifier->tokenizer = get_tokenizer ("osb-text");
}
- cfg->classifiers = g_list_prepend (cfg->classifiers, cur_classifier);
+ yacc_cfg->classifiers = g_list_prepend (yacc_cfg->classifiers, cur_classifier);
cur_classifier = NULL;
}
;
classifiertype:
TYPE EQSIGN QUOTEDSTRING {
- cur_classifier = check_classifier_cfg (cfg, cur_classifier);
+ cur_classifier = check_classifier_cfg (yacc_cfg, cur_classifier);
if ((cur_classifier->classifier = get_classifier ($3)) == NULL) {
yyerror ("yyparse: unknown classifier type: %s", $3);
YYERROR;
;
classifiertokenizer:
TOKENIZER EQSIGN QUOTEDSTRING {
- cur_classifier = check_classifier_cfg (cfg, cur_classifier);
+ cur_classifier = check_classifier_cfg (yacc_cfg, cur_classifier);
if ((cur_classifier->tokenizer = get_tokenizer ($3)) == NULL) {
yyerror ("yyparse: unknown tokenizer %s", $3);
YYERROR;
classifiermetric:
METRIC EQSIGN QUOTEDSTRING {
- cur_classifier = check_classifier_cfg (cfg, cur_classifier);
+ cur_classifier = check_classifier_cfg (yacc_cfg, cur_classifier);
cur_classifier->metric = $3;
- memory_pool_add_destructor (cfg->cfg_pool, g_free, cur_classifier->metric);
+ memory_pool_add_destructor (yacc_cfg->cfg_pool, g_free, cur_classifier->metric);
}
;
classifieroption:
PARAM EQSIGN QUOTEDSTRING {
- cur_classifier = check_classifier_cfg (cfg, cur_classifier);
+ cur_classifier = check_classifier_cfg (yacc_cfg, cur_classifier);
g_hash_table_insert (cur_classifier->opts, $1, $3);
- memory_pool_add_destructor (cfg->cfg_pool, g_free, $1);
- memory_pool_add_destructor (cfg->cfg_pool, g_free, $3);
+ memory_pool_add_destructor (yacc_cfg->cfg_pool, g_free, $1);
+ memory_pool_add_destructor (yacc_cfg->cfg_pool, g_free, $3);
};
statfile:
yyerror ("yyparse: not enough arguments in statfile definition");
YYERROR;
}
- cur_classifier = check_classifier_cfg (cfg, cur_classifier);
+ cur_classifier = check_classifier_cfg (yacc_cfg, cur_classifier);
cur_classifier->statfiles = g_list_prepend (cur_classifier->statfiles, cur_statfile);
- cfg->statfiles = g_list_prepend (cfg->statfiles, cur_statfile);
+ yacc_cfg->statfiles = g_list_prepend (yacc_cfg->statfiles, cur_statfile);
cur_statfile = NULL;
}
;
statfilesymbol:
SYMBOL EQSIGN QUOTEDSTRING {
- cur_classifier = check_classifier_cfg (cfg, cur_classifier);
+ cur_classifier = check_classifier_cfg (yacc_cfg, cur_classifier);
if (cur_statfile == NULL) {
- cur_statfile = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct statfile));
+ cur_statfile = memory_pool_alloc0 (yacc_cfg->cfg_pool, sizeof (struct statfile));
}
- cur_statfile->symbol = memory_pool_strdup (cfg->cfg_pool, $3);
- g_hash_table_insert (cfg->classifiers_symbols, $3, cur_classifier);
+ cur_statfile->symbol = memory_pool_strdup (yacc_cfg->cfg_pool, $3);
+ g_hash_table_insert (yacc_cfg->classifiers_symbols, $3, cur_classifier);
}
;
statfilepath:
PATH EQSIGN QUOTEDSTRING {
if (cur_statfile == NULL) {
- cur_statfile = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct statfile));
+ cur_statfile = memory_pool_alloc0 (yacc_cfg->cfg_pool, sizeof (struct statfile));
}
- cur_statfile->path = memory_pool_strdup (cfg->cfg_pool, $3);
+ cur_statfile->path = memory_pool_strdup (yacc_cfg->cfg_pool, $3);
}
;
statfilesize:
SIZE EQSIGN NUMBER {
if (cur_statfile == NULL) {
- cur_statfile = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct statfile));
+ cur_statfile = memory_pool_alloc0 (yacc_cfg->cfg_pool, sizeof (struct statfile));
}
cur_statfile->size = $3;
}
| SIZE EQSIGN SIZELIMIT {
if (cur_statfile == NULL) {
- cur_statfile = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct statfile));
+ cur_statfile = memory_pool_alloc0 (yacc_cfg->cfg_pool, sizeof (struct statfile));
}
cur_statfile->size = $3;
}
statfilesection:
SECTION OBRACE sectionbody EBRACE {
if (cur_statfile == NULL) {
- cur_statfile = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct statfile));
+ cur_statfile = memory_pool_alloc0 (yacc_cfg->cfg_pool, sizeof (struct statfile));
}
if (cur_section == NULL || cur_section->code == 0) {
yyerror ("yyparse: error in section definition");
sectionname:
NAME EQSIGN QUOTEDSTRING {
if (cur_section == NULL) {
- cur_section = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct statfile_section));
+ cur_section = memory_pool_alloc0 (yacc_cfg->cfg_pool, sizeof (struct statfile_section));
}
cur_section->code = statfile_get_section_by_name ($3);
}
sectionsize:
SIZE EQSIGN NUMBER {
if (cur_section == NULL) {
- cur_section = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct statfile_section));
+ cur_section = memory_pool_alloc0 (yacc_cfg->cfg_pool, sizeof (struct statfile_section));
}
cur_section->size = $3;
}
| SIZE EQSIGN SIZELIMIT {
if (cur_section == NULL) {
- cur_section = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct statfile_section));
+ cur_section = memory_pool_alloc0 (yacc_cfg->cfg_pool, sizeof (struct statfile_section));
}
cur_section->size = $3;
}
sectionweight:
WEIGHT EQSIGN NUMBER {
if (cur_section == NULL) {
- cur_section = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct statfile_section));
+ cur_section = memory_pool_alloc0 (yacc_cfg->cfg_pool, sizeof (struct statfile_section));
}
cur_section->weight = $3;
}
| WEIGHT EQSIGN FRACT {
if (cur_section == NULL) {
- cur_section = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct statfile_section));
+ cur_section = memory_pool_alloc0 (yacc_cfg->cfg_pool, sizeof (struct statfile_section));
}
cur_section->weight = $3;
}
statfileautolearn:
AUTOLEARN OBRACE autolearnbody EBRACE {
if (cur_statfile == NULL) {
- cur_statfile = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct statfile));
+ cur_statfile = memory_pool_alloc0 (yacc_cfg->cfg_pool, sizeof (struct statfile));
}
if (cur_autolearn == NULL) {
yyerror ("yyparse: error in autolearn definition");
autolearnmetric:
METRIC EQSIGN QUOTEDSTRING {
if (cur_autolearn == NULL) {
- cur_autolearn = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct statfile_autolearn_params));
+ cur_autolearn = memory_pool_alloc0 (yacc_cfg->cfg_pool, sizeof (struct statfile_autolearn_params));
}
- cur_autolearn->metric = memory_pool_strdup (cfg->cfg_pool, $3);
+ cur_autolearn->metric = memory_pool_strdup (yacc_cfg->cfg_pool, $3);
}
;
autolearnmin:
MIN_MARK EQSIGN NUMBER {
if (cur_autolearn == NULL) {
- cur_autolearn = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct statfile_autolearn_params));
+ cur_autolearn = memory_pool_alloc0 (yacc_cfg->cfg_pool, sizeof (struct statfile_autolearn_params));
}
cur_autolearn->threshold_min = $3;
}
| MIN_MARK EQSIGN FRACT {
if (cur_autolearn == NULL) {
- cur_autolearn = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct statfile_autolearn_params));
+ cur_autolearn = memory_pool_alloc0 (yacc_cfg->cfg_pool, sizeof (struct statfile_autolearn_params));
}
cur_autolearn->threshold_min = $3;
}
autolearnmax:
MAX_MARK EQSIGN NUMBER {
if (cur_autolearn == NULL) {
- cur_autolearn = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct statfile_autolearn_params));
+ cur_autolearn = memory_pool_alloc0 (yacc_cfg->cfg_pool, sizeof (struct statfile_autolearn_params));
}
cur_autolearn->threshold_max = $3;
}
| MAX_MARK EQSIGN FRACT {
if (cur_autolearn == NULL) {
- cur_autolearn = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct statfile_autolearn_params));
+ cur_autolearn = memory_pool_alloc0 (yacc_cfg->cfg_pool, sizeof (struct statfile_autolearn_params));
}
cur_autolearn->threshold_max = $3;
}
autolearnsymbols:
SYMBOLS EQSIGN QUOTEDSTRING {
if (cur_autolearn == NULL) {
- cur_autolearn = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct statfile_autolearn_params));
+ cur_autolearn = memory_pool_alloc0 (yacc_cfg->cfg_pool, sizeof (struct statfile_autolearn_params));
}
- cur_autolearn->symbols = parse_comma_list (cfg->cfg_pool, $3);
+ cur_autolearn->symbols = parse_comma_list (yacc_cfg->cfg_pool, $3);
}
;
statfilebinlog:
BINLOG EQSIGN QUOTEDSTRING {
if (cur_statfile == NULL) {
- cur_statfile = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct statfile));
+ cur_statfile = memory_pool_alloc0 (yacc_cfg->cfg_pool, sizeof (struct statfile));
}
if (cur_statfile->binlog == NULL) {
- cur_statfile->binlog = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct statfile_binlog_params));
+ cur_statfile->binlog = memory_pool_alloc0 (yacc_cfg->cfg_pool, sizeof (struct statfile_binlog_params));
}
if (g_ascii_strcasecmp ($3, "master") == 0) {
cur_statfile->binlog->affinity = AFFINITY_MASTER;
statfilebinlogrotate:
BINLOG_ROTATE EQSIGN QUOTEDSTRING {
if (cur_statfile == NULL) {
- cur_statfile = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct statfile));
+ cur_statfile = memory_pool_alloc0 (yacc_cfg->cfg_pool, sizeof (struct statfile));
}
if (cur_statfile->binlog == NULL) {
- cur_statfile->binlog = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct statfile_binlog_params));
+ cur_statfile->binlog = memory_pool_alloc0 (yacc_cfg->cfg_pool, sizeof (struct statfile_binlog_params));
}
cur_statfile->binlog->rotate_time = parse_seconds ($3);
}
statfilebinlogmaster:
BINLOG_MASTER EQSIGN QUOTEDSTRING {
if (cur_statfile == NULL) {
- cur_statfile = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct statfile));
+ cur_statfile = memory_pool_alloc0 (yacc_cfg->cfg_pool, sizeof (struct statfile));
}
if (cur_statfile->binlog == NULL) {
- cur_statfile->binlog = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct statfile_binlog_params));
+ cur_statfile->binlog = memory_pool_alloc0 (yacc_cfg->cfg_pool, sizeof (struct statfile_binlog_params));
}
if (!parse_host_port ($3, &cur_statfile->binlog->master_addr, &cur_statfile->binlog->master_port)) {
YYERROR;
statfilenormalizer:
NORMALIZER EQSIGN QUOTEDSTRING {
- if (!parse_normalizer (cfg, cur_statfile, $3)) {
+ if (!parse_normalizer (yacc_cfg, cur_statfile, $3)) {
yyerror ("cannot parse normalizer string: %s", $3);
YYERROR;
}
- cur_statfile->normalizer_str = memory_pool_strdup (cfg->cfg_pool, $3);
+ cur_statfile->normalizer_str = memory_pool_strdup (yacc_cfg->cfg_pool, $3);
}
;
statfile_pool_size:
STATFILE_POOL_SIZE EQSIGN SIZELIMIT {
- cfg->max_statfile_size = $3;
+ yacc_cfg->max_statfile_size = $3;
}
| STATFILE_POOL_SIZE EQSIGN NUMBER {
- cfg->max_statfile_size = $3;
+ yacc_cfg->max_statfile_size = $3;
}
;
raw_mode:
RAW_MODE EQSIGN FLAG {
- cfg->raw_mode = $3;
+ yacc_cfg->raw_mode = $3;
}
;
profile_file:
PROFILE_FILE EQSIGN QUOTEDSTRING {
#ifdef WITH_GPREF_TOOLS
- cfg->profile_path = $3;
+ yacc_cfg->profile_path = $3;
#else
yywarn ("yyparse: profile_file directive is ignored as gperf support is not enabled");
#endif
yyerror ("yyparse: not enough arguments in view definition");
YYERROR;
}
- cfg->views = g_list_prepend (cfg->views, cur_view);
+ yacc_cfg->views = g_list_prepend (yacc_cfg->views, cur_view);
cur_view = NULL;
}
;
viewip:
IP EQSIGN QUOTEDSTRING {
if (cur_view == NULL) {
- cur_view = init_view (cfg->cfg_pool);
+ cur_view = init_view (yacc_cfg->cfg_pool);
}
if (!add_view_ip (cur_view, $3)) {
yyerror ("yyparse: invalid ip line in view definition: ip = '%s'", $3);
viewclientip:
CLIENT_IP EQSIGN QUOTEDSTRING {
if (cur_view == NULL) {
- cur_view = init_view (cfg->cfg_pool);
+ cur_view = init_view (yacc_cfg->cfg_pool);
}
if (!add_view_client_ip (cur_view, $3)) {
yyerror ("yyparse: invalid ip line in view definition: ip = '%s'", $3);
viewfrom:
FROM EQSIGN QUOTEDSTRING {
if (cur_view == NULL) {
- cur_view = init_view (cfg->cfg_pool);
+ cur_view = init_view (yacc_cfg->cfg_pool);
}
if (!add_view_from (cur_view, $3)) {
yyerror ("yyparse: invalid from line in view definition: from = '%s'", $3);
viewsymbols:
SYMBOLS EQSIGN QUOTEDSTRING {
if (cur_view == NULL) {
- cur_view = init_view (cfg->cfg_pool);
+ cur_view = init_view (yacc_cfg->cfg_pool);
}
if (!add_view_symbols (cur_view, $3)) {
yyerror ("yyparse: invalid symbols line in view definition: symbols = '%s'", $3);
viewskipcheck:
SKIP_CHECK EQSIGN FLAG {
if (cur_view == NULL) {
- cur_view = init_view (cfg->cfg_pool);
+ cur_view = init_view (yacc_cfg->cfg_pool);
}
cur_view->skip_check = $3;
}
usersettings:
USER_SETTINGS EQSIGN QUOTEDSTRING {
- if (!read_settings ($3, cfg, cfg->user_settings)) {
+ if (!read_settings ($3, yacc_cfg, yacc_cfg->user_settings)) {
yyerror ("yyparse: cannot read settings %s", $3);
YYERROR;
}
- cfg->user_settings_str = memory_pool_strdup (cfg->cfg_pool, $3);
+ yacc_cfg->user_settings_str = memory_pool_strdup (yacc_cfg->cfg_pool, $3);
}
;
domainsettings:
DOMAIN_SETTINGS EQSIGN QUOTEDSTRING {
- if (!read_settings ($3, cfg, cfg->domain_settings)) {
+ if (!read_settings ($3, yacc_cfg, yacc_cfg->domain_settings)) {
yyerror ("yyparse: cannot read settings %s", $3);
YYERROR;
}
- cfg->domain_settings_str = memory_pool_strdup (cfg->cfg_pool, $3);
+ yacc_cfg->domain_settings_str = memory_pool_strdup (yacc_cfg->cfg_pool, $3);
}
;
%%
/* 2 seconds to fork new process in place of dead one */
#define SOFT_FORK_TIME 2
-struct config_file *cfg;
rspamd_hash_t *counters;
static struct rspamd_worker *fork_worker (struct rspamd_main *, struct worker_conf *);
+static gboolean load_rspamd_config (struct config_file *cfg);
+static void init_metrics_cache (struct config_file *cfg);
sig_atomic_t do_restart;
sig_atomic_t do_terminate;
GQueue *signals_info;
#endif
+/* Yacc vars */
extern int yynerrs;
extern FILE *yyin;
+struct config_file *yacc_cfg;
static gboolean config_test;
static gboolean no_fork;
static gboolean dump_vars;
static gboolean dump_cache;
-#ifndef WITHOUT_PERL
-extern void xs_init (pTHX);
-extern PerlInterpreter *perl_interpreter;
-#endif
-
/* List of workers that are pending to start */
static GList *workers_pending = NULL;
+/* List of active listen sockets indexed by worker type */
+static GHashTable *listen_sockets;
+
/* Commandline options */
static GOptionEntry entries[] =
{
{
struct config_file *tmp_cfg;
char *cfg_file;
- FILE *f;
+ GList *l;
+ struct filter *filt;
tmp_cfg = (struct config_file *)g_malloc (sizeof (struct config_file));
if (tmp_cfg) {
tmp_cfg->cfg_pool = memory_pool_new (memory_pool_get_size ());
init_defaults (tmp_cfg);
cfg_file = memory_pool_strdup (tmp_cfg->cfg_pool, rspamd->cfg->cfg_name);
- f = fopen (rspamd->cfg->cfg_name, "r");
- if (f == NULL) {
- msg_warn ("cannot open file: %s", rspamd->cfg->cfg_name);
+ /* Save some variables */
+ tmp_cfg->cfg_name = cfg_file;
+ tmp_cfg->lua_state = rspamd->cfg->lua_state;
+
+ if (! load_rspamd_config (tmp_cfg)) {
+ msg_err ("cannot parse new config file, revert to old one");
+ free_config (tmp_cfg);
}
else {
- yyin = f;
- yyrestart (yyin);
+ msg_debug ("replacing config");
+ free_config (rspamd->cfg);
+ close_log ();
+ g_free (rspamd->cfg);
+ rspamd->cfg = tmp_cfg;
+ post_load_config (rspamd->cfg);
+ config_logger (rspamd, FALSE);
+ /* Perform modules configuring */
+ l = g_list_first (rspamd->cfg->filters);
- if (yyparse () != 0 || yynerrs > 0) {
- msg_warn ("yyparse: cannot parse config file, %d errors", yynerrs);
- fclose (f);
- }
- else {
- msg_debug ("replacing config");
- free_config (rspamd->cfg);
- close_log ();
- g_free (rspamd->cfg);
- rspamd->cfg = tmp_cfg;
- rspamd->cfg->cfg_name = cfg_file;
- config_logger (rspamd, FALSE);
- open_log ();
- msg_info ("config rereaded successfully");
+ while (l) {
+ filt = l->data;
+ if (filt->module) {
+ (void)filt->module->module_config_func (rspamd->cfg);
+ }
+ l = g_list_next (l);
}
+ init_metrics_cache (rspamd->cfg);
+ msg_info ("config rereaded successfully");
}
}
}
cur = (struct rspamd_worker *)g_malloc (sizeof (struct rspamd_worker));
if (cur) {
bzero (cur, sizeof (struct rspamd_worker));
- g_queue_push_head (cf->active_workers, cur);
cur->srv = rspamd;
cur->type = cf->type;
cur->pid = fork ();
- cur->cf = cf;
+ cur->cf = g_malloc (sizeof (struct worker_conf));
+ memcpy (cur->cf, cf, sizeof (struct worker_conf));
cur->pending = FALSE;
switch (cur->pid) {
case 0:
/* Update pid for logging */
update_log_pid ();
/* Drop privilleges */
- drop_priv (cfg);
+ drop_priv (rspamd->cfg);
/* Set limits */
set_worker_limits (cf);
switch (cf->type) {
static void
-dump_cfg_vars ()
+dump_cfg_vars (struct config_file *cfg)
{
g_hash_table_foreach (cfg->variables, dump_all_variables, NULL);
}
}
static void
-spawn_workers (struct rspamd_main *rspamd, gboolean make_sockets)
+spawn_workers (struct rspamd_main *rspamd)
{
GList *cur;
struct worker_conf *cf;
int i, listen_sock;
+ gpointer p;
- cur = cfg->workers;
+ cur = rspamd->cfg->workers;
while (cur) {
cf = cur->data;
- if (make_sockets && cf->has_socket) {
- /* Create listen socket */
- listen_sock = create_listen_socket (&cf->bind_addr, cf->bind_port, cf->bind_family, cf->bind_host);
- if (listen_sock == -1) {
- exit (-errno);
+ if (cf->has_socket) {
+ if ((p = g_hash_table_lookup (listen_sockets, GINT_TO_POINTER (cf->type))) == NULL) {
+ /* Create listen socket */
+ listen_sock = create_listen_socket (&cf->bind_addr, cf->bind_port, cf->bind_family, cf->bind_host);
+ if (listen_sock == -1) {
+ exit (-errno);
+ }
+ g_hash_table_insert (listen_sockets, GINT_TO_POINTER (cf->type), GINT_TO_POINTER (listen_sock));
+ }
+ else {
+ /* We had socket for this type of worker */
+ listen_sock = GPOINTER_TO_INT (p);
}
cf->listen_sock = listen_sock;
}
waitpid (w->pid, &res, 0);
msg_debug ("%s process %P terminated", get_process_type (w->type), w->pid);
+ g_free (w->cf);
g_free (w);
return TRUE;
return EBADF;
}
yyin = f;
-
+
+ yacc_cfg = rspamd->cfg;
if (yyparse () != 0 || yynerrs > 0) {
msg_err ("cannot parse config file, %d errors", yynerrs);
return EBADF;
}
static gboolean
-load_rspamd_config (struct rspamd_main *rspamd)
+load_rspamd_config (struct config_file *cfg)
{
GList *l;
struct filter *filt;
struct module_ctx *cur_module = NULL;
- if (! read_xml_config (rspamd->cfg, rspamd->cfg->cfg_name)) {
+ if (! read_xml_config (cfg, cfg->cfg_name)) {
return FALSE;
}
/* Strictly set temp dir */
- if (!rspamd->cfg->temp_dir) {
+ if (!cfg->temp_dir) {
msg_warn ("tempdir is not set, trying to use $TMPDIR");
- rspamd->cfg->temp_dir = memory_pool_strdup (rspamd->cfg->cfg_pool, getenv ("TMPDIR"));
+ cfg->temp_dir = memory_pool_strdup (cfg->cfg_pool, getenv ("TMPDIR"));
- if (!rspamd->cfg->temp_dir) {
+ if (!cfg->temp_dir) {
msg_warn ("$TMPDIR is empty too, using /tmp as default");
- rspamd->cfg->temp_dir = memory_pool_strdup (rspamd->cfg->cfg_pool, "/tmp");
+ cfg->temp_dir = memory_pool_strdup (cfg->cfg_pool, "/tmp");
}
}
/* Do post-load actions */
- post_load_config (rspamd->cfg);
- /* Init counters */
- counters = rspamd_hash_new_shared (rspamd->server_pool, g_str_hash, g_str_equal, 64);
+ post_load_config (cfg);
/* Init C modules */
- l = g_list_first (rspamd->cfg->filters);
+ l = g_list_first (cfg->filters);
while (l) {
filt = l->data;
if (filt->module) {
- cur_module = memory_pool_alloc (rspamd->cfg->cfg_pool, sizeof (struct module_ctx));
+ cur_module = memory_pool_alloc (cfg->cfg_pool, sizeof (struct module_ctx));
if (filt->module->module_init_func (cfg, &cur_module) == 0) {
g_hash_table_insert (cfg->c_modules, (gpointer) filt->module->name, cur_module);
}
return TRUE;
}
+static void
+init_metrics_cache (struct config_file *cfg)
+{
+ struct metric *metric;
+ GList *l;
+
+ /* Init symbols cache for each metric */
+ l = g_list_first (cfg->metrics_list);
+ while (l) {
+ metric = l->data;
+ if (metric->cache && !init_symbols_cache (cfg->cfg_pool, metric->cache, metric->cache_filename)) {
+ exit (EXIT_FAILURE);
+ }
+ l = g_list_next (l);
+ }
+}
+
+static void
+print_metrics_cache (struct config_file *cfg)
+{
+ struct metric *metric;
+ GList *l;
+ struct cache_item *item;
+ int i;
+
+ l = g_list_first (cfg->metrics_list);
+ while (l) {
+ metric = l->data;
+ if (!init_symbols_cache (cfg->cfg_pool, metric->cache, metric->cache_filename)) {
+ exit (EXIT_FAILURE);
+ }
+ if (metric->cache) {
+ printf ("Cache for metric: %s\n", metric->name);
+ printf ("-----------------------------------------------------------------\n");
+ printf ("| Pri | Symbol | Weight | Frequency | Avg. time |\n");
+ for (i = 0; i < metric->cache->used_items; i++) {
+ item = &metric->cache->items[i];
+ printf ("-----------------------------------------------------------------\n");
+ printf ("| %3d | %22s | %6.1f | %9d | %9.3f |\n", i, item->s->symbol, item->s->weight, item->s->frequency, item->s->avg_time);
+
+ }
+ printf ("-----------------------------------------------------------------\n");
+ }
+ l = g_list_next (l);
+ }
+}
+
int
main (int argc, char **argv, char **env)
{
struct rspamd_main *rspamd;
- int res = 0, i;
+ int res = 0;
struct sigaction signals;
struct rspamd_worker *cur;
struct rlimit rlim;
- struct metric *metric;
- struct cache_item *item;
struct filter *filt;
pid_t wrk;
GList *l;
-#ifndef WITHOUT_PERL
- char *args[] = { "", "-e", "0", NULL };
-#endif
#ifdef HAVE_SA_SIGINFO
signals_info = g_queue_new ();
rspamd = (struct rspamd_main *)g_malloc (sizeof (struct rspamd_main));
bzero (rspamd, sizeof (struct rspamd_main));
rspamd->server_pool = memory_pool_new (memory_pool_get_size ());
- cfg = (struct config_file *)g_malloc (sizeof (struct config_file));
- rspamd->cfg = cfg;
+ rspamd->cfg = (struct config_file *)g_malloc (sizeof (struct config_file));
if (!rspamd || !rspamd->cfg) {
fprintf (stderr, "Cannot allocate memory\n");
exit (-errno);
child_dead = 0;
do_reopen_log = 0;
+#ifndef HAVE_SETPROCTITLE
+ init_title (argc, argv, environ);
+#endif
+
rspamd->stat = memory_pool_alloc_shared (rspamd->server_pool, sizeof (struct rspamd_stat));
bzero (rspamd->stat, sizeof (struct rspamd_stat));
rspamd->cfg->cfg_name = FIXED_CONFIG_FILE;
}
- if (cfg->config_test) {
- cfg->log_level = G_LOG_LEVEL_DEBUG;
+ if (rspamd->cfg->config_test) {
+ rspamd->cfg->log_level = G_LOG_LEVEL_DEBUG;
}
else {
- cfg->log_level = G_LOG_LEVEL_CRITICAL;
+ rspamd->cfg->log_level = G_LOG_LEVEL_CRITICAL;
}
#ifdef HAVE_SETLOCALE
/* First set logger to console logger */
rspamd_set_logger (RSPAMD_LOG_CONSOLE, rspamd->cfg);
(void)open_log ();
- g_log_set_default_handler (rspamd_glib_log_function, cfg);
+ g_log_set_default_handler (rspamd_glib_log_function, rspamd->cfg);
-#ifndef HAVE_SETPROCTITLE
- init_title (argc, argv, environ);
-#endif
- init_lua (cfg);
+ init_lua (rspamd->cfg);
+
+ /* Init counters */
+ counters = rspamd_hash_new_shared (rspamd->server_pool, g_str_hash, g_str_equal, 64);
+ /* Init listen sockets hash */
+ listen_sockets = g_hash_table_new (g_direct_hash, g_direct_equal);
if (convert_config != NULL) {
if (! convert_old_config (rspamd)) {
}
}
- if (! load_rspamd_config (rspamd)) {
+ if (! load_rspamd_config (rspamd->cfg)) {
exit (EXIT_FAILURE);
}
- if (cfg->config_test || dump_vars || dump_cache) {
+ if (rspamd->cfg->config_test || dump_vars || dump_cache) {
/* Init events to test modules */
event_init ();
res = TRUE;
while (l) {
filt = l->data;
if (filt->module) {
- if (!filt->module->module_config_func (cfg)) {
+ if (!filt->module->module_config_func (rspamd->cfg)) {
res = FALSE;
}
}
l = g_list_next (l);
}
- init_lua_filters (cfg);
+ init_lua_filters (rspamd->cfg);
if (dump_vars) {
- dump_cfg_vars ();
+ dump_cfg_vars (rspamd->cfg);
}
if (dump_cache) {
- l = g_list_first (cfg->metrics_list);
- while (l) {
- metric = l->data;
- if (!init_symbols_cache (cfg->cfg_pool, metric->cache, metric->cache_filename)) {
- exit (EXIT_FAILURE);
- }
- if (metric->cache) {
- printf ("Cache for metric: %s\n", metric->name);
- printf ("-----------------------------------------------------------------\n");
- printf ("| Pri | Symbol | Weight | Frequency | Avg. time |\n");
- for (i = 0; i < metric->cache->used_items; i++) {
- item = &metric->cache->items[i];
- printf ("-----------------------------------------------------------------\n");
- printf ("| %3d | %22s | %6.1f | %9d | %9.3f |\n", i, item->s->symbol, item->s->weight, item->s->frequency, item->s->avg_time);
-
- }
- printf ("-----------------------------------------------------------------\n");
- }
- l = g_list_next (l);
- }
+ print_metrics_cache (rspamd->cfg);
exit (EXIT_SUCCESS);
}
fprintf (stderr, "syntax %s\n", res ? "OK" : "BAD");
setproctitle ("main process");
/* Init statfile pool */
- rspamd->statfile_pool = statfile_pool_new (cfg->max_statfile_size);
+ rspamd->statfile_pool = statfile_pool_new (rspamd->cfg->max_statfile_size);
event_init ();
g_mime_init (0);
while (l) {
filt = l->data;
if (filt->module) {
- if (!filt->module->module_config_func (cfg)) {
+ if (!filt->module->module_config_func (rspamd->cfg)) {
res = FALSE;
}
}
l = g_list_next (l);
}
-#ifndef WITHOUT_PERL
- /* Init perl interpreter */
- dTHXa (perl_interpreter);
- PERL_SYS_INIT3 (&argc, &argv, &env);
- perl_interpreter = perl_alloc ();
- if (perl_interpreter == NULL) {
- msg_err ("cannot allocate perl interpreter, %s", strerror (errno));
- exit (-errno);
- }
-
- PERL_SET_CONTEXT (perl_interpreter);
- perl_construct (perl_interpreter);
- perl_parse (perl_interpreter, xs_init, 3, args, NULL);
- init_perl_filters (cfg);
-#endif
-
- init_lua_filters (cfg);
+ init_lua_filters (rspamd->cfg);
/* Init symbols cache for each metric */
- l = g_list_first (cfg->metrics_list);
- while (l) {
- metric = l->data;
- if (metric->cache && !init_symbols_cache (cfg->cfg_pool, metric->cache, metric->cache_filename)) {
- exit (EXIT_FAILURE);
- }
- l = g_list_next (l);
- }
+ init_metrics_cache (rspamd->cfg);
flush_log_buf ();
rspamd->workers = g_hash_table_new (g_direct_hash, g_direct_equal);
- spawn_workers (rspamd, TRUE);
+ spawn_workers (rspamd);
/* Signal processing cycle */
for (;;) {
/* Unlink dead process from queue and hash table */
g_hash_table_remove (rspamd->workers, GSIZE_TO_POINTER (wrk));
- g_queue_remove (cur->cf->active_workers, cur);
if (WIFEXITED (res) && WEXITSTATUS (res) == 0) {
/* Normal worker termination, do not fork one more */
msg_info ("rspamd " RVERSION " is restarting");
g_hash_table_foreach (rspamd->workers, kill_old_workers, NULL);
- spawn_workers (rspamd, FALSE);
+ reread_config (rspamd);
+ spawn_workers (rspamd);
}
if (got_alarm) {