diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-07-24 08:33:49 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-07-24 08:33:49 +0100 |
commit | e853ac873adbf4730f5c6593a410da310df35cac (patch) | |
tree | 84d8a6cdf1af332f96ffbbec1826953d16a3a729 /src/libserver | |
parent | 6b71fcb72fce2945cca43cc2acc141b507655273 (diff) | |
download | rspamd-e853ac873adbf4730f5c6593a410da310df35cac.tar.gz rspamd-e853ac873adbf4730f5c6593a410da310df35cac.zip |
[Minor] Store parent pid inside workers
Diffstat (limited to 'src/libserver')
-rw-r--r-- | src/libserver/rspamd_control.c | 18 | ||||
-rw-r--r-- | src/libserver/worker_util.c | 3 |
2 files changed, 18 insertions, 3 deletions
diff --git a/src/libserver/rspamd_control.c b/src/libserver/rspamd_control.c index c8080f99e..279d47d6b 100644 --- a/src/libserver/rspamd_control.c +++ b/src/libserver/rspamd_control.c @@ -397,6 +397,10 @@ rspamd_control_broadcast_cmd (struct rspamd_main *rspamd_main, while (g_hash_table_iter_next (&it, &k, &v)) { wrk = v; + if (wrk->control_pipe[0] == -1) { + continue; + } + memset (&msg, 0, sizeof (msg)); /* Attach fd to the message */ @@ -433,8 +437,10 @@ rspamd_control_broadcast_cmd (struct rspamd_main *rspamd_main, DL_APPEND (res, rep_elt); } else { - msg_err ("cannot write request to the worker %P (%s): %s", - wrk->pid, g_quark_to_string (wrk->type), strerror (errno)); + msg_err ("cannot write request to the worker %P(%s), fd: %d: %s", + wrk->pid, g_quark_to_string (wrk->type), + wrk->control_pipe[0], + strerror (errno)); } } @@ -754,6 +760,7 @@ rspamd_control_handle_on_fork (struct rspamd_srv_command *cmd, return; } + REF_RELEASE (child->cf); g_hash_table_remove (srv->workers, GSIZE_TO_POINTER (cmd->cmd.on_fork.ppid)); g_free (child); @@ -763,6 +770,13 @@ rspamd_control_handle_on_fork (struct rspamd_srv_command *cmd, child->srv = srv; child->type = parent->type; child->pid = cmd->cmd.on_fork.cpid; + child->srv_pipe[0] = -1; + child->srv_pipe[1] = -1; + child->control_pipe[0] = -1; + child->control_pipe[1] = -1; + child->cf = parent->cf; + child->ppid = parent->pid; + REF_RETAIN (child->cf); g_hash_table_insert (srv->workers, GSIZE_TO_POINTER (cmd->cmd.on_fork.cpid), child); } diff --git a/src/libserver/worker_util.c b/src/libserver/worker_util.c index 1fd6c3555..7753fa1b3 100644 --- a/src/libserver/worker_util.c +++ b/src/libserver/worker_util.c @@ -546,13 +546,14 @@ rspamd_fork_worker (struct rspamd_main *rspamd_main, wrk->index = index; wrk->ctx = cf->ctx; wrk->finish_actions = g_ptr_array_new (); - + wrk->ppid = getpid (); wrk->pid = fork (); switch (wrk->pid) { case 0: /* Update pid for logging */ rspamd_log_update_pid (cf->type, rspamd_main->logger); + wrk->pid = getpid (); /* Init PRNG after fork */ rc = ottery_init (rspamd_main->cfg->libs_ctx->ottery_cfg); |