"controller", /* Name */
init_controller_worker, /* Init function */
start_controller_worker, /* Start function */
- TRUE, /* Has socket */
- TRUE, /* Non unique */
- FALSE, /* Non threaded */
- TRUE, /* Killable */
+ RSPAMD_WORKER_HAS_SOCKET | RSPAMD_WORKER_KILLABLE,
SOCK_STREAM, /* TCP socket */
RSPAMD_WORKER_VER /* Version info */
};
void start_fuzzy (struct rspamd_worker *worker);
worker_t fuzzy_worker = {
- "fuzzy", /* Name */
- init_fuzzy, /* Init function */
- start_fuzzy, /* Start function */
- TRUE, /* No socket */
- FALSE, /* Unique */
- FALSE, /* Threaded */
- FALSE, /* Non killable */
- SOCK_DGRAM, /* UDP socket */
- RSPAMD_WORKER_VER /* Version info */
+ "fuzzy", /* Name */
+ init_fuzzy, /* Init function */
+ start_fuzzy, /* Start function */
+ RSPAMD_WORKER_HAS_SOCKET,
+ SOCK_DGRAM, /* UDP socket */
+ RSPAMD_WORKER_VER /* Version info */
};
/* For evtimer */
"hs_helper", /* Name */
init_hs_helper, /* Init function */
start_hs_helper, /* Start function */
- FALSE, /* No socket */
- TRUE, /* Unique */
- FALSE, /* Non threaded */
- TRUE, /* Killable */
+ RSPAMD_WORKER_UNIQUE|RSPAMD_WORKER_KILLABLE|RSPAMD_WORKER_ALWAYS_START,
SOCK_STREAM, /* TCP socket */
RSPAMD_WORKER_VER /* Version info */
};
"http_proxy", /* Name */
init_http_proxy, /* Init function */
start_http_proxy, /* Start function */
- TRUE, /* Has socket */
- FALSE, /* Non unique */
- FALSE, /* Non threaded */
- TRUE, /* Killable */
+ RSPAMD_WORKER_HAS_SOCKET | RSPAMD_WORKER_KILLABLE,
SOCK_STREAM, /* TCP socket */
RSPAMD_WORKER_VER
};
"lua", /* Name */
init_lua_worker, /* Init function */
start_lua_worker, /* Start function */
- TRUE, /* Has socket */
- FALSE, /* Non unique */
- FALSE, /* Non threaded */
- TRUE, /* Killable */
+ RSPAMD_WORKER_HAS_SOCKET | RSPAMD_WORKER_KILLABLE,
SOCK_STREAM, /* TCP socket */
RSPAMD_WORKER_VER /* Version info */
};
{
gint i;
- if (cf->worker->unique) {
+ if (!(cf->worker->flags & RSPAMD_WORKER_UNIQUE)) {
if (cf->count > 1) {
msg_warn_main (
"cannot spawn more than 1 %s worker, so spawn one",
}
rspamd_fork_worker (rspamd_main, cf, 0, ev_base);
}
- else if (cf->worker->threaded) {
+ else if (cf->worker->flags & RSPAMD_WORKER_THREADED) {
rspamd_fork_worker (rspamd_main, cf, 0, ev_base);
}
else {
msg_err_main ("type of worker is unspecified, skip spawning");
}
else {
- if (cf->worker->has_socket) {
+ if (cf->worker->flags & RSPAMD_WORKER_HAS_SOCKET) {
LL_FOREACH (cf->bind_conf, bcf) {
key = make_listen_key (bcf);
if ((p =
if (waitpid (w->pid, &res, WNOHANG) <= 0) {
if (term_attempts == 0) {
- if (w->cf->worker->killable) {
+ if (w->cf->worker->flags & RSPAMD_WORKER_KILLABLE) {
msg_info_main ("terminate worker %P with SIGKILL", w->pid);
kill (w->pid, SIGKILL);
}
#endif
#define RSPAMD_CUR_MODULE_VERSION 0x1
-#define RSPAMD_CUR_WORKER_VERSION 0x1
+#define RSPAMD_CUR_WORKER_VERSION 0x2
#define RSPAMD_FEATURES \
RSPAMD_FEATURE_HYPERSCAN RSPAMD_FEATURE_PCRE2 \
const gchar *rspamd_features;
} module_t;
+enum rspamd_worker_flags {
+ RSPAMD_WORKER_HAS_SOCKET = (1 << 0),
+ RSPAMD_WORKER_UNIQUE = (1 << 1),
+ RSPAMD_WORKER_THREADED = (1 << 2),
+ RSPAMD_WORKER_KILLABLE = (1 << 3),
+ RSPAMD_WORKER_ALWAYS_START = (1 << 4),
+};
+
typedef struct worker_s {
const gchar *name;
gpointer (*worker_init_func)(struct rspamd_config *cfg);
void (*worker_start_func)(struct rspamd_worker *worker);
- gboolean has_socket;
- gboolean unique;
- gboolean threaded;
- gboolean killable;
+ enum rspamd_worker_flags flags;
gint listen_type;
guint worker_version;
guint64 rspamd_version;
"smtp_proxy", /* Name */
init_smtp_proxy, /* Init function */
start_smtp_proxy, /* Start function */
- TRUE, /* Has socket */
- FALSE, /* Non unique */
- FALSE, /* Non threaded */
- TRUE, /* Killable */
+ RSPAMD_WORKER_HAS_SOCKET | RSPAMD_WORKER_KILLABLE,
SOCK_STREAM, /* TCP socket */
RSPAMD_WORKER_VER /* Version info */
};
void start_worker (struct rspamd_worker *worker);
worker_t normal_worker = {
- "normal", /* Name */
- init_worker, /* Init function */
- start_worker, /* Start function */
- TRUE, /* Has socket */
- FALSE, /* Non unique */
- FALSE, /* Non threaded */
- TRUE, /* Killable */
- SOCK_STREAM, /* TCP socket */
- RSPAMD_WORKER_VER /* Version info */
+ "normal", /* Name */
+ init_worker, /* Init function */
+ start_worker, /* Start function */
+ RSPAMD_WORKER_HAS_SOCKET|RSPAMD_WORKER_KILLABLE,
+ SOCK_STREAM, /* TCP socket */
+ RSPAMD_WORKER_VER /* Version info */
};
#define msg_err_ctx(...) rspamd_default_log_function(G_LOG_LEVEL_CRITICAL, \