############################ TARGETS SECTION ###############################
ADD_CUSTOM_COMMAND(OUTPUT ${LEX_OUTPUT}
- COMMAND ${LEX_EXECUTABLE} -o${LEX_OUTPUT} ${LEX_SRC})
+ COMMAND ${LEX_EXECUTABLE} -o${LEX_OUTPUT} ${LEX_SRC}
+ DEPENDS ${LEX_SRC})
ADD_CUSTOM_COMMAND(OUTPUT ${YACC_OUTPUT}
- COMMAND ${YACC_EXECUTABLE} -d -o ${YACC_OUTPUT} ${YACC_SRC})
+ COMMAND ${YACC_EXECUTABLE} -d -o ${YACC_OUTPUT} ${YACC_SRC}
+ DEPENDS ${YACC_SRC})
ADD_CUSTOM_COMMAND(OUTPUT src/modules.c
COMMAND ../utils/gen-modules.sh ${PLUGINSSRC}
WORKING_DIRECTORY src)
IF(PERL_EXECUTABLE)
ADD_CUSTOM_COMMAND(OUTPUT perl/Makefile
+ PRE_BUILD
COMMAND ${PERL_EXECUTABLE} ./Makefile.PL
WORKING_DIRECTORY perl)
CONFIGURE_FILE(perl/Makefile.PL.in perl/Makefile.PL)
uint16_t bind_port; /**< bind port in case of TCP socket */
uint16_t bind_family; /**< bind type (AF_UNIX or AF_INET) */
int count; /**< number of workers */
- GHashTable *params; /**< params for worker */
int listen_sock; /**< listening socket desctiptor */
+ uint32_t rlimit_nofile; /**< max files limit */
+ uint32_t rlimit_maxcore; /**< maximum core file size */
+ GHashTable *params; /**< params for worker */
GQueue *active_workers; /**< linked list of spawned workers */
gboolean has_socket; /**< whether we should make listening socket in main process */
};
GList *views; /**< views */
GHashTable* domain_settings; /**< settings per-domains */
GHashTable* user_settings; /**< settings per-user */
+
};
/**
user_settings return USER_SETTINGS;
domain_settings return DOMAIN_SETTINGS;
+maxfiles return MAXFILES;
+maxcore return MAXCORE;
+
filters return FILTERS;
factors return FACTORS;
grow_factor return GROW_FACTOR;
%token STATFILE ALIAS PATTERN WEIGHT STATFILE_POOL_SIZE SIZE TOKENIZER CLASSIFIER BINLOG BINLOG_MASTER BINLOG_ROTATE
%token DELIVERY LMTP ENABLED AGENT SECTION LUACODE RAW_MODE PROFILE_FILE COUNT
%token VIEW IP FROM SYMBOLS CLIENT_IP
-%token AUTOLEARN MIN_MARK MAX_MARK
+%token AUTOLEARN MIN_MARK MAX_MARK MAXFILES MAXCORE
%token SETTINGS USER_SETTINGS DOMAIN_SETTINGS SYMBOL PATH SKIP_CHECK GROW_FACTOR
%type <string> STRING
| bindsock
| workertype
| workercount
+ | workerlimitfiles
+ | workerlimitcore
| workerparam
;
}
;
+workerlimitfiles:
+ MAXFILES EQSIGN NUMBER {
+ cur_worker = check_worker_conf (cfg, cur_worker);
+ cur_worker->rlimit_nofile = $3;
+ }
+ ;
+
+workerlimitcore:
+ MAXCORE EQSIGN NUMBER {
+ cur_worker = check_worker_conf (cfg, cur_worker);
+ cur_worker->rlimit_maxcore = $3;
+ }
+ ;
+
workerparam:
STRING EQSIGN QUOTEDSTRING {
cur_worker = check_worker_conf (cfg, cur_worker);
#define DEFAULT_SCORE 10.0
+#define DEFAULT_RLIMIT_NOFILE 2048
+#define DEFAULT_RLIMIT_MAXCORE 0
+
extern int yylineno;
extern char *yytext;
#else
c->count = DEFAULT_WORKERS_NUM;
#endif
+ c->rlimit_nofile = DEFAULT_RLIMIT_NOFILE;
+ c->rlimit_maxcore = DEFAULT_RLIMIT_MAXCORE;
}
return c;
}
}
+static void
+set_worker_limits (struct worker_conf *cf)
+{
+ struct rlimit rlmt;
+
+ if (cf->rlimit_nofile != 0) {
+ rlmt.rlim_cur = (rlim_t) cf->rlimit_nofile;
+ rlmt.rlim_max = (rlim_t) cf->rlimit_nofile;
+
+ if (setrlimit(RLIMIT_NOFILE, &rlmt) == -1) {
+ msg_warn ("set_worker_limits: cannot set files rlimit: %d, %s", cf->rlimit_nofile, strerror (errno));
+ }
+ }
+
+ if (cf->rlimit_maxcore != 0) {
+ rlmt.rlim_cur = (rlim_t) cf->rlimit_maxcore;
+ rlmt.rlim_max = (rlim_t) cf->rlimit_maxcore;
+
+ if (setrlimit(RLIMIT_CORE, &rlmt) == -1) {
+ msg_warn ("set_worker_limits: cannot set max core rlimit: %d, %s", cf->rlimit_maxcore, strerror (errno));
+ }
+ }
+
+}
+
static struct rspamd_worker *
fork_worker (struct rspamd_main *rspamd, struct worker_conf *cf)
{
case 0:
/* Drop privilleges */
drop_priv (cfg);
+ /* Set limits */
+ set_worker_limits (cf);
switch (cf->type) {
case TYPE_CONTROLLER:
setproctitle ("controller process");
s = ntohl (task->from_addr.s_addr);
while (cur) {
addr = cur->data;
- if (addr->mask == 0) {
- m = 0;
- }
- else {
- m = G_MAXUINT32 << (32 - addr->mask);
- }
- if ((s & m) == (addr->addr & m)) {
- switch (addr->mech) {
- case SPF_FAIL:
- insert_result (task, spf_module_ctx->metric, spf_module_ctx->symbol_fail, 1, g_list_prepend (NULL, addr->spf_string));
- break;
- case SPF_SOFT_FAIL:
- case SPF_NEUTRAL:
- insert_result (task, spf_module_ctx->metric, spf_module_ctx->symbol_softfail, 1, g_list_prepend (NULL, addr->spf_string));
- break;
- default:
- insert_result (task, spf_module_ctx->metric, spf_module_ctx->symbol_allow, 1, g_list_prepend (NULL, addr->spf_string));
- break;
- }
- /* Stop parsing */
- break;
- }
+ if (addr != NULL) {
+ if (addr->mask == 0) {
+ m = 0;
+ }
+ else {
+ m = G_MAXUINT32 << (32 - addr->mask);
+ }
+ if ((s & m) == (addr->addr & m)) {
+ switch (addr->mech) {
+ case SPF_FAIL:
+ insert_result (task, spf_module_ctx->metric, spf_module_ctx->symbol_fail, 1, g_list_prepend (NULL, addr->spf_string));
+ break;
+ case SPF_SOFT_FAIL:
+ case SPF_NEUTRAL:
+ insert_result (task, spf_module_ctx->metric, spf_module_ctx->symbol_softfail, 1, g_list_prepend (NULL, addr->spf_string));
+ break;
+ default:
+ insert_result (task, spf_module_ctx->metric, spf_module_ctx->symbol_allow, 1, g_list_prepend (NULL, addr->spf_string));
+ break;
+ }
+ /* Stop parsing */
+ break;
+ }
+ }
cur = g_list_next (cur);
}
}