static gboolean
rspamd_fuzzy_storage_sync (struct rspamd_main *rspamd_main,
struct rspamd_worker *worker, gint fd,
+ gint attached_fd,
struct rspamd_control_command *cmd,
gpointer ud)
{
static gboolean
rspamd_fuzzy_storage_reload (struct rspamd_main *rspamd_main,
struct rspamd_worker *worker, gint fd,
+ gint attached_fd,
struct rspamd_control_command *cmd,
gpointer ud)
{
static gboolean
rspamd_fuzzy_storage_stat (struct rspamd_main *rspamd_main,
struct rspamd_worker *worker, gint fd,
+ gint attached_fd,
struct rspamd_control_command *cmd,
gpointer ud)
{
static gboolean
rspamd_hs_helper_reload (struct rspamd_main *rspamd_main,
struct rspamd_worker *worker, gint fd,
+ gint attached_fd,
struct rspamd_control_command *cmd,
gpointer ud)
{
static void
rspamd_control_default_cmd_handler (gint fd,
+ gint attached_fd,
struct rspamd_worker_control_data *cd,
struct rspamd_control_command *cmd)
{
{
struct rspamd_worker_control_data *cd = ud;
struct rspamd_control_command cmd;
-
+ struct msghdr msg;
+ struct iovec iov;
+ guchar fdspace[CMSG_SPACE(sizeof (int))];
+ gint rfd = -1;
gssize r;
- r = read (fd, &cmd, sizeof (cmd));
+ iov.iov_base = &cmd;
+ iov.iov_len = sizeof (cmd);
+ memset (&msg, 0, sizeof (msg));
+ msg.msg_control = fdspace;
+ msg.msg_controllen = sizeof (fdspace);
+ msg.msg_iov = &iov;
+ msg.msg_iovlen = 1;
+
+ r = recvmsg (fd, &msg, 0);
if (r == -1) {
msg_err ("cannot read request from the control socket: %s",
}
else if ((gint)cmd.type >= 0 && cmd.type < RSPAMD_CONTROL_MAX) {
+ if (msg.msg_controllen >= CMSG_SPACE(sizeof (int))) {
+ rfd = *(int *) CMSG_DATA(CMSG_FIRSTHDR (&msg));
+ }
+
if (cd->handlers[cmd.type].handler) {
- cd->handlers[cmd.type].handler (cd->worker->srv, cd->worker,
- fd, &cmd, cd->handlers[cmd.type].ud);
+ cd->handlers[cmd.type].handler (cd->worker->srv,
+ cd->worker,
+ fd,
+ rfd,
+ &cmd,
+ cd->handlers[cmd.type].ud);
}
else {
- rspamd_control_default_cmd_handler (fd, cd, &cmd);
+ rspamd_control_default_cmd_handler (fd, rfd, cd, &cmd);
}
}
else {
struct {
gint forced;
} hs_loaded;
+ struct {
+ enum rspamd_log_pipe_type type;
+ } log_pipe;
} reply;
};
typedef gboolean (*rspamd_worker_control_handler) (struct rspamd_main *rspamd_main,
- struct rspamd_worker *worker, gint fd,
+ struct rspamd_worker *worker,
+ gint fd,
+ gint attached_fd,
struct rspamd_control_command *cmd,
gpointer ud);
G_STRFUNC, \
__VA_ARGS__)
+struct rspamd_worker_log_pipe {
+ gint fd;
+ enum rspamd_log_pipe_type type;
+ struct rspamd_worker_log_pipe *prev, *next;
+};
+
/*
* Worker's context
*/
static gboolean
rspamd_worker_hyperscan_ready (struct rspamd_main *rspamd_main,
struct rspamd_worker *worker, gint fd,
+ gint attached_fd,
struct rspamd_control_command *cmd,
gpointer ud)
{