"controller", /* Name */
init_controller_worker, /* Init function */
start_controller_worker, /* Start function */
- RSPAMD_WORKER_HAS_SOCKET | RSPAMD_WORKER_KILLABLE,
+ RSPAMD_WORKER_HAS_SOCKET | RSPAMD_WORKER_KILLABLE |
+ RSPAMD_WORKER_SCANNER | RSPAMD_WORKER_CONTROLLER,
RSPAMD_WORKER_SOCKET_TCP, /* TCP socket */
RSPAMD_WORKER_VER /* Version info */
};
diff);
}
- if (rspamd_worker_is_normal (task->worker)) {
+ if (rspamd_worker_is_scanner (task->worker)) {
rspamd_set_counter (item->cd, diff);
}
double_to_tv (tm, &tv);
event_add (&cbdata->resort_ev, &tv);
- if (rspamd_worker_is_normal (cbdata->w)) {
+ if (rspamd_worker_is_scanner (cbdata->w)) {
rspamd_mempool_lock_mutex (cache->mtx);
/* Gather stats from shared execution times */
wrk->srv = rspamd_main;
wrk->type = cf->type;
wrk->cf = cf;
+ wrk->flags = cf->worker->flags;
REF_RETAIN (cf);
wrk->index = index;
wrk->ctx = cf->ctx;
}
gboolean
-rspamd_worker_is_normal (struct rspamd_worker *w)
+rspamd_worker_is_scanner (struct rspamd_worker *w)
{
- static GQuark normal_quark = (GQuark)0;
if (w) {
- if (normal_quark) {
- return w->type == normal_quark;
- }
- else {
- normal_quark = g_quark_from_static_string ("normal");
- }
-
- return w->type == normal_quark;
+ return !!(w->flags & RSPAMD_WORKER_SCANNER);
}
return FALSE;
* @param w
* @return
*/
-gboolean rspamd_worker_is_normal (struct rspamd_worker *w);
+gboolean rspamd_worker_is_scanner (struct rspamd_worker *w);
/**
* Creates new session cache
LUA_FUNCTION_DEF (worker, get_stat);
LUA_FUNCTION_DEF (worker, get_index);
LUA_FUNCTION_DEF (worker, get_pid);
+LUA_FUNCTION_DEF (worker, is_scanner);
LUA_FUNCTION_DEF (worker, spawn_process);
const luaL_reg worker_reg[] = {
LUA_INTERFACE_DEF (worker, get_index),
LUA_INTERFACE_DEF (worker, get_pid),
LUA_INTERFACE_DEF (worker, spawn_process),
+ LUA_INTERFACE_DEF (worker, is_scanner),
{"__tostring", rspamd_lua_class_tostring},
{NULL, NULL}
};
return 1;
}
+
+static gint
+lua_worker_is_scanner (lua_State *L)
+{
+ struct rspamd_worker *w = lua_check_worker (L, 1);
+
+ if (w) {
+ lua_pushboolean (L, rspamd_worker_is_scanner (w));
+ }
+ else {
+ return luaL_error (L, "invalid arguments");
+ }
+
+ return 1;
+}
+
struct rspamd_lua_process_cbdata {
gint sp[2];
gint func_cbref;
#define CR '\r'
#define LF '\n'
+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),
+ RSPAMD_WORKER_SCANNER = (1 << 5),
+ RSPAMD_WORKER_CONTROLLER = (1 << 6),
+};
+
+
/**
* Worker process structure
*/
GList *accept_events; /**< socket events */
struct rspamd_worker_conf *cf; /**< worker config data */
gpointer ctx; /**< worker's specific data */
+ enum rspamd_worker_flags flags; /**< worker's flags */
gint control_pipe[2]; /**< control pipe. [0] is used by main process,
[1] is used by a worker */
gint srv_pipe[2]; /**< used by workers to request something from the
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),
-};
-
enum rspamd_worker_socket_type {
RSPAMD_WORKER_SOCKET_NONE = 0,
RSPAMD_WORKER_SOCKET_TCP = (1 << 0),
"rspamd_proxy", /* Name */
init_rspamd_proxy, /* Init function */
start_rspamd_proxy, /* Start function */
- RSPAMD_WORKER_HAS_SOCKET | RSPAMD_WORKER_KILLABLE,
+ RSPAMD_WORKER_HAS_SOCKET | RSPAMD_WORKER_KILLABLE | RSPAMD_WORKER_SCANNER,
RSPAMD_WORKER_SOCKET_TCP, /* TCP socket */
RSPAMD_WORKER_VER
};
"normal", /* Name */
init_worker, /* Init function */
start_worker, /* Start function */
- RSPAMD_WORKER_HAS_SOCKET|RSPAMD_WORKER_KILLABLE,
+ RSPAMD_WORKER_HAS_SOCKET|RSPAMD_WORKER_KILLABLE|RSPAMD_WORKER_SCANNER,
RSPAMD_WORKER_SOCKET_TCP, /* TCP socket */
RSPAMD_WORKER_VER /* Version info */
};